3 ms·
Decimal floating point floats are exactly as weird as binary floating points. The only difference is that different numbers are representible. You still have:
by constantcrying 3y ago
Decimal floating point floats are exactly as weird as binary floating points.
The only difference is that different numbers are representible. You still have:
- They do not obey mathematical laws for real numbers
- Equality comparison is meaningless
- Multiple operation lead to unboundedly large errors
>Experts that handle applications with "real" numbers can then explicitly switch to "weird float". It is worth a thought.
The weirdness does not go away in decimal floats. It is exactly as weird.
>One could argue that for many use cases (most spreadsheets handling money amounts, for example) computers are powerful enough now that "non-integer numbers" should default to some base-10 floating point
Base 10 floats do not fix money amounts. (1/3)3 is not* equal to 1 in base 10 floats. You can not correctly handle money with floats, as money is not arbitrarily dividable. Changing to base 10 does not fix that.
The core problem with money is that the divison operation is not well defined. As for example $3.333... is not an amount of money that can exist. Even the mathematically correct operations are wrong, you can not fix that with imperfect approximations.
- FabHK 3y agoYou don't fix all problems. But you fix some, for example 0.1 + 0.2 == 0.3 in base 10 floats. And what you see is what you get. 1/3 = 0.333333, rounded, makes sense. 0.333333 x 3 = 0.999999, makes sense.
- constantcrying 3y agoNo. You fix zero problems. >But you fix some, for example 0.1 + 0.2 == 0.3 in base 10 floats. And you get the exact same amount of NEW problems. You are just shifting around where they are. 0.1 + 0.2 != 0.3 also makes a lot of sense, if you have tiniest knowledge about floats.