Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where currency can play an ugly joke
Message
 
 
À
14/02/2005 17:48:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00986817
Message ID:
00986848
Vues:
25
>
>? NTOM(MTON($9)*(1/3))
>
Yes, that's correct if you want a currency data type for the result.

>This is ok for me ( and you ? ) but when Bill G. have to split they patrimony:
>
>? ($9999999999999.9999/3)*3
>?  NTOM(MTON($9999999999999.9999)*(1/3))*3
>
As I'm sure you already know, VFP can handle numbers up to 9007199254740992 (2^53) with 16 digits of precision. Working at the limit, your first example
?(900719925474.0992/3)*3
gives a correct result.

For compound calculations the best practice is to derive intermediate results explicitly. Breaking your second example into two steps
lnx = MTON($900719925474.0992) * 1/3
?NTOM( lnx * 3)
also gives the correct result.
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform