Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numeric digits of precision
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00626806
Message ID:
00628643
Vues:
16
Bob,

I haven't looked at Hilmar's code at all, but if he's doing floating point arithmetic and using log() functions to do it then 2^2 is not going to be exactly 4.

There is a fundamental difference in the representation of integers and floats in memory. Integers will always be precise. Floats will always be subject to rounding errors in the mantissa.

set decimals to 15
lfp1 = log(2)
? lfp1 && this number is not exactly 0.693147180559945 as VFP displays it. In the scientifc calculator mode the number is 0.69314718055994530941723212145818 this value is irrational, there is no end to the number of decimal places that this number has
lfp1 = lfp1 * 2 && raise it to the second power
? exp( lfp1 ) && convert from logarithm, VFP is showing you 4.00000000000000 but it's not exactly that number because of rounding errors those bits are just lost

Do a google search on mantissa, exponent and epsilon if you want to get more detail on floating point calculations. My first BS degree is in Nuclear Engineering and I cut my computing eyeteeth doing Fortran code. *s*

>>Floating point numbers are rarely ever "accurate" especially when you
>>bring functions like log() into the mix, because the constants used
>>in the calculation can't be expressed in 32, 64 or even an infinite
>>number of bits.
>
>I understand about lack of precision when it comes to LOG(). I don't understand lack of precision when it comes to 2^2.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform