Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Rounding with BCDs |
Tue, Feb 16 2010 4:49 PM | Permanent Link |
Donat Hebert | With all fields defined as BCD, 2 decimal, the rounding always yields a integer, yet the
target field is defined to receive two decimals. Update TN Set FTY_Value = ABS((FTY_Numerator/FTY_Denominator)*100) Commit Interval 500 ; ie 24/31 Ans: 77.00 If I cast or define the two source fields as float, the result is correct. Ans: 77.42 DBSIAM 4.29 B2. Donat. |
Tue, Feb 16 2010 6:26 PM | Permanent Link |
"Robert" | "Donat Hebert" <donat.hebert@worldsoft.ca> wrote in message news:D2379615-C11F-4EC5-AD36-A4E3DD9DF942@news.elevatesoft.com... > With all fields defined as BCD, 2 decimal, the rounding always yields a > integer, yet the > target field is defined to receive two decimals. > > Update TN > Set FTY_Value = ABS((FTY_Numerator/FTY_Denominator)*100) > Commit Interval 500 ; > ie 24/31 Ans: 77.00 > > If I cast or define the two source fields as float, the result is correct. > Ans: 77.42 > > DBSIAM 4.29 B2. > > Donat. > You need more decimals in FTY_Value to get what you want. The result of the first calculation is 0.77 when you multiply by 100 you get 77.00. If you had a BCD with 4 decimals then the result would be 0.7742 when multiplied by 100 yields 77.42 Robert |
Tue, Feb 16 2010 6:44 PM | Permanent Link |
"Robert" | "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message news:0FBEA4A3-4242-460B-BAA5-C70AA3D5200B@news.elevatesoft.com... > > > You need more decimals in FTY_Value to get what you want. The result of > the first calculation is 0.77 when you multiply by 100 you get 77.00. If > you had a BCD with 4 decimals then the result would be 0.7742 when > multiplied by 100 yields 77.42 > Sorry after the lecture forgot to give you the solution do the multiplication first abs(f1 * 100 / f2) Robert |
Tue, Feb 16 2010 10:15 PM | Permanent Link |
Donat Hebert | Thanks Robert, that solution will be just fine without expanding the number of decimals.
Donat. "Robert" wrote: "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message news:0FBEA4A3-4242-460B-BAA5-C70AA3D5200B@news.elevatesoft.com... > > > You need more decimals in FTY_Value to get what you want. The result of > the first calculation is 0.77 when you multiply by 100 you get 77.00. If > you had a BCD with 4 decimals then the result would be 0.7742 when > multiplied by 100 yields 77.42 > Sorry after the lecture forgot to give you the solution do the multiplication first abs(f1 * 100 / f2) Robert |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |