Re: Stange problem with sprintf or trace display

new topic     » goto parent     » topic index » view thread      » older message » newer message
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu