Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Rounding with BCDs
Tue, Feb 16 2010 4:49 PMPermanent 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 PMPermanent 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 PMPermanent 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 PMPermanent 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
Image