News for hackers. Stuff that matters.
Re:Floating point error is the least of my worries (2011) by jcranmer on Wednesday February 21, 2018 @10:57PM (#16435050)
Decimal floating point is really no better than binary floating point, and suggesting that people should use it instead suggests that you don't actually understand what floating point is really about.

If you're dealing with money, for example, you'll want to use fixed-point, not any kind of floating point. Floating point expands its range by effectively representing numbers uniformly across the log space. If you need to deal with calculations that contain both 1e-12 and 1e12, you really want that logarithmic property. But money has a fixed scale: you don't need to represent any numbers between 0 and 0.01¢ (fractional cents are useful, but I think 1/100 is the smallest you'd need). A 64-bit binary floating number at that scale can only precisely store every number up to a tad over $900 billion, and even decimal floating point can only scooch that up to a tad under $1 trillion. A 64-bit integer in fixed point could handle $1.8 quadrillion precisely.

Decimal floating point doesn't fix rounding errors. It fixes superficial rounding error in that 0.1 is a terminating decimal in base 10 but not in base 2, but that's not really a problem that happens. It doesn't fix the fact that subtraction and division have the potential to destroy significant digits, and it doesn't fix the inability to accurately mix large and small numbers--both of which cause many more problems in practice, particularly when you try to do things like invert a matrix.

There are no comments on this comment yet.