3 ms·
The problem is that instructions for ieee754 values use the full precision of those values (or greater), when you almost never need that much. And if you leave
by kstenerud 7y ago
The problem is that instructions for ieee754 values use the full precision of those values (or greater), when you almost never need that much. And if you leave them as-is, you build up bias.
As your calculations progress, your results slowly build up significant digit bias (which will be different depending on the architecture and libraries). To get around this, you'd have to round regularly, but that also slows things down (and is difficult to do in binary float).
If you're taking the results of calculations at their full precision, you're just asking for trouble. 32-bit binary ieee754 may be able to represent 7 digits of precision, but I sure as hell wouldn't take the results of 32-bit float operations to more than 6!
The alternative is to get a contract from the compiler that everything will be done in the same precision with the same bias for the specified type, and just accept the buildup (which we're currently doing without that guarantee, and getting burned by it).