Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error in calculations?
Message
From
11/07/2004 10:37:43
 
 
To
11/07/2004 09:26:44
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00923104
Message ID:
00923113
Views:
25
Isn't that true for many languages? I remember long time ago using intergers only to represent cents (100 cent= 1 Dollar)

Peter

>
>How can I trust Visual FoxPro arithmetics after this?
>

>
>This is a design VFP behaviour.
>
>Run this:
>
>CLEAR
>SET FIXED OFF
>SET DECIMALS TO RAND()*18  && THIS IS insignificant
>y = 100.00000000
>for n = 1 to 1000
> y = y - .10000000
>NEXT
>? y=0,y*3=0,y*4=0,Y+Y+Y+Y=0
>
>y is zero, y*3 is zero, but y*4 is not zero ( and this is a bug )
>
>
>VFP store any variable decimal number with a IEEE float format.
>0.1 have not a exact IEEE value, and therefore every calculation introduces round errors.
>
>You can use ROUND(), but it is not perfect.
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform