4 ms·
Except it does fix gradual precision loss, because that loss is incurred by the decimal-to-binary loss that exists in pretty much every human-input value (in te
by kstenerud 5y ago
Except it does fix gradual precision loss, because that loss is incurred by the decimal-to-binary loss that exists in pretty much every human-input value (in text conversion AND in source code).
Need to do a bunch of multiplications by 0.2 and 0.3? Well you've lost precision on every operation because those multiplicands weren't actually 0.2 and 0.3 since they got converted to close binary float values. If they where decimal floats, you'd have control over the process because it would be exactly decimal and you could apply standard significant digit rounding with predictable results like we do with calculators.
TBH I think the main problem is that people just aren't aware of how binary floats actually work, and instead latch upon the "floats are imprecise" mantra and call it a day. So nothing ever gets fixed because nobody knows to demand it.
- jcranmer 5y agoIt fixes gradual precision loss only if you assume every value was perfectly precise to begin with, and if you never ever try to divide (or I guess use any operation other then +, -, and ×). 1 / 3 is still an imprecise number in decimal floating point. The only numbers I'd be reasonably certain of such a precision input would be financial values, and the precision loss still kicks in if you do operations as mundane as averaging values, let alone trying to do some linear algebra (as in doing operations analysis). By the time you get to a lot of scientific or engineering applications, your input numbers are already imprecise to begin with (and a lot of times, they're already coming from something like a 12-bit counter or the like).
- kstenerud 5y agoThe same thing happens when you use a calculator. And yet nobody says "don't use a calculator; you lose too much precision."