Information générale
Catégorie:
Codage, syntaxe et commandes
Jesse, Fred:
Try this in VBA:
Dim x As Double
x = 3.999999999999999
MsgBox x
MsgBox Int(x)
and you will get the same results as in VFP. In fact, if you do it in the Word VBA (I have not tried with the other Office programs), the line x = 3.999999999999999 will display as x=4#. As I tried to explain in an earlier post, this is due to the fact that most fractions (3999999999999999 / 1000000000000000 in this case) don't have an finite binary representation. The "problem" is that computer works with 0 and 1, not 0,1,2,..9 and thus you are tempted to believe that 3.999999999999999 has an finite representation (because it has an finite number of digits after the decimnals) when in fact it doesn't. Truth is, the binary representation of that number represents a range of number.
Hope I am more clear this time.
Daniel
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement