Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rounding problem
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00681174
Message ID:
00681235
Views:
20
Jon,

15,000,000 does not have the exact same value in both equations, the round() function forces 3 decimals on the end. I think it is the same as this, and this yields the same result:
? 15000000.000*.01721250*82/360  && yields 58809.37499999999
I would not count on a high degree of accuracy in floating point math in *any* programming language. I would also be more inclined to round the end result:
? round(15000000.000*.01721250*82.000/360.000,3)   && 58809.375
As to whether this could cause a big accounting problem, I dunno. If your numbers are evenly distributed, how often will this scenario occur? Sometimes it may erroneously round up a penny, other times down. Usually it will be right. On average, it should be right.

What do you think?

BTW, Hilmar has a file in downloads for doing calculations with high accuracy...maybe it would help in this situation. I think it converts number to strings and performs calculations manually (long-hand). I don't recall if it performs multiplication and division yet.

>
>OK, I'll accept that. Now, consider this equation:
>
15000000*.01721250*82/360
>This produces a result of 58809.375.
>
>However,
>
ROUND(15000000,3)*.01721250*82/360
>will produce 58809.37499999999
>
>Now, as far as I can see 15,000,000 is the exact same value in both equations because everything to the right of the decimal is zero. What is the explanation for the difference in results? This phenomenon does not happen on my calculator, nor does it happen in Excel. The reason I'm harping on this is because this is showing up in our interest calc/accounting application. Mutiply that problem by a whole lot of trades and you have a big accounting problem. :)
>
>Jon
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform