3 ms·
From the article: "I am not a theoretician and have not proven that this is actually correct." So, yes, you might get away with floating point values for finan
by andrewaylett 7y ago
From the article: "I am not a theoretician and have not proven that this is actually correct."
So, yes, you might get away with floating point values for financials -- and I have even seen banking code that did -- but that doesn't mean it's a good idea. Especially when libraries providing fixed point and arbitrary precision decimal representations are widely available and easy to use.
The biggest problem with using IEE 754 for currencies is that IEE 754 defines a domain and a set of operations that don't match the domain and set of operations required for currency calculations. The discrepancies between the "right" answers and the answers given by IEE 754 aren't because IEE 754 is in some way "wrong", it's because it's not calculating what you think it's calculating.
- projektfu 7y agoI once had to send a bug report to a big bank, like Bank of America, because their JavaScript front end wasn’t rounding and got the typical 0.1+0.2>0.3 error (or whatever). This meant that I couldn’t submit a dispute online and had to do it on the phone. Like most companies, they don’t bother thanking you, or letting you know if it’s fixed. It’s great how coding style books rarely address these important things and focus only on bookshedding. Anyone know of a good presubmit checklist for semantic issues?