Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Currency calculations. Bug?
Message
 
To
31/03/2011 10:00:45
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01505515
Message ID:
01505712
Views:
37
>Yuri,
>
>it's a well known fact between mathematicians that multiplication should ALWAYS be done before a division in order to preserve the precision. One good example:
>1*3/3 = 3/3 =1.
>1/3*3 = 0.33333333333333333333333333333333*3=0.99999999999999999999999999999999
>
>>Thanks for the reply.
>>
>>Though I do not share your both opinions about parentheses or the multiplication should go first.
>>I see them as a workarounds similar to MTON that I used in my original post.
>>Not to mention that either you need to know in advance that you are dealing with the currency type, or you need to check the type in the code prior to process calculaltion
>>
>>From my point of view, it is a bug or at least a special "feature" that is not documented in VFP Help.
>>
>>Thanks


Trying to represent the problem and dealing with replyes, I eventually forgot the actual expression in the code where I discovered this behavior:

?fldcur * (n2/n1-1) && 7050.0000
?(n2/n1-1) * fldcur && 7050.0000


Looks like neither parentheses nor order of operations help here.
Previous
Reply
Map
View

Click here to load this message in the networking platform