Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where currency can play an ugly joke
Message
From
14/02/2005 18:58:24
 
 
To
14/02/2005 17:48:34
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00986817
Message ID:
00986848
Views:
26
>
>? 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.
Previous
Reply
Map
View

Click here to load this message in the networking platform