Re: Stange problem with sprintf or trace display
- Posted by mattlewis (admin) Mar 13, 2012
- 1117 views
AJ_Oxley said...
Hello gurus...
My app was adding up dollars and cents but did not balance.
A simplified example of why not is given below:
...
This is whacky! any ideas?
In general, you should not use floating point arithmetic for financial purposes. You're seeing rounding errors due to the fact that floating point numbers are stored in binary, and there are many decimal fractions that cannot be represented exactly.
Matt