Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error in calculations?
Message
De
11/07/2004 10:37:43
 
 
À
11/07/2004 09:26:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00923104
Message ID:
00923113
Vues:
24
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform