Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incorrect rounging of 6 digits pecision
Message
From
22/04/2002 15:27:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
22/04/2002 15:16:22
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00647785
Message ID:
00647799
Views:
15
>I need to use 6 digits precision fields in my free tables.
>However, the FoxPro all versions round incorrectly those fields.
>
>How to get correct result from the following sample ?
>
>
>
>CREATE cursor t1 ( price n(9,6) )
>INSERT INTO t1 VALUES ( 16.95 )
>CREATE cursor t2 ( quantity n(8,6) )
>INSERT INTO t2 VALUES ( 1.5 )
>
>?ROUND( t1.price*t2.quantity,2)
>* Displayed result: 25.42
>* Expected result: 25.43
>
Perhaps the round() function would help in this case. I believe that in some cases, VFP shows the value truncated instead of rounded.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform