Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Str() how many decimal places can I be sure of
Message
De
03/01/2002 08:30:31
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
03/01/2002 07:37:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00600182
Message ID:
00600212
Vues:
23
>Hi Alexandre
>
>Do you know why issuing a STR(85.76,32,14) gives me
>" 85.76000000000001" I want to know where the spurious 1 is coming from at the end. I'm sure I've read something somewhere about the limited accuracy of decimal places when converting to a string but I can't remember where
>
>Thanks
>
>Simon

Real numbers are stored internally as binary numbers, and have to be converted back and forth to decimals. There are other sources of innacuracies as well; in other programming languages you learn that you can't make a trustworth comparison (if A = B) involving real numbers (FoxPro has solved this problem for most cases).

You simply have to be aware of the limited accuracy, and use workarounds in some cases.

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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform