Not at all, no.
-
-
How much do you owe on a $1 transaction with 4.9% sales tax? Under this scheme, you'd represent this as 100¢ × 104.9%, which gets you a value that is close to but not equal to 104.9.pic.twitter.com/6yTcN8s7Zm
2 replies 0 retweets 1 like -
You check your local applicable law to see what rounding mode you need to apply, and apply that to get back to full cents.
1 reply 0 retweets 0 likes -
Replying to @andreasdotorg @jxxf and
Note that actually knowing the fractional part (up to a certain precision) allows you to apply the correct rounding mode, unlike what happens when calculating using integers, where truncation always happens.
1 reply 0 retweets 0 likes -
In my experience, "use floating-point, manage the bookkeeping yourself, and pray you don't get unlucky with error propagation" is much more prone to errors than "use a decimal type".
1 reply 0 retweets 1 like -
Until you hit an integer overflow, and things go belly up in pretty dramatic ways.
1 reply 0 retweets 0 likes -
Replying to @andreasdotorg @jxxf and
But my entire point here is that using floats is perfectly fine for money, if you follow a small number of rules, whereas using regexes for HTML parsing is bound to fail due to HTML being a recursive language, and regexes recognizing regular languages.
2 replies 0 retweets 2 likes -
I think that's fair. My point is that it's not necessarily obvious you're getting burned by FPEP until you're in deep, whereas it's usually clear if a regex isn't returning what you think it should. A lot of F500s have lost a lot of money to very silly FP errors!
1 reply 0 retweets 1 like -
I've never heard of any such case. Even if you use floats incorrectly, the accumulated error tends to be small.
1 reply 0 retweets 0 likes -
In financial calculations, it's common to iterate over a large number of periods (e.g., mortgages, bond payments, and so on) or a large number of transactions (e.g., all the payroll checks). Adding or subtracting iteratively easily leads to catastrophic cancellations with FPs.
2 replies 0 retweets 0 likes
The worst that can happen, when actually using fractional float values for fractional dollars, is that you have a list of items worth a dollar, and the total is displayed as 99 cents or $1.01.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.