Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error in calculations?
Message
From
11/07/2004 09:26:44
 
 
To
11/07/2004 08:15:53
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00923104
Message ID:
00923109
Views:
22

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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform