3 ms·
IEEE Floating point rounds numbers in binary, not in decimal. So it is trivial by simply having a 54-bit register to hold the 53-bit mantissa. So the answer to
by dragontamer 13y ago
IEEE Floating point rounds numbers in binary, not in decimal. So it is trivial by simply having a 54-bit register to hold the 53-bit mantissa.
So the answer to your question is... Floating Point numbers "don't round correctly". They're actually quite complicated, and require careful study.
- stromgo 13y agoMy example has nothing to do with decimal rounding. It's an example of a product (6172293634027511 * 7059478094414279) whose result is extremely close to the fence between two representable numbers (4837593847918366.5 * 2^53). If the 106-bit product happened to be 2 units smaller, then the rounded result would change.
- dragontamer 13y agoAs stated before, Floating Point numbers "don't round correctly" according to IEEE Floating Point arithmetic. There are very simple rules on how to round. This makes calculation of errors a bit complicated. http://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules http://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_ru... At best, Intel at one point provided 80-bit rounding (ie: 68-bit mantissa). That is, if you use the x87 floating-point coprocessor. But these technically do not match IEEE specifications for rounding.
- fdej 13y agoEr, what? Floating point numbers do "round correctly" (in binary) -- that's pretty much the whole point of the IEEE standard. In particular, to compute a product of two 53-bit floating-point numbers with correct rounding (as the standard mandates), it is certainly not sufficient in general to compute just a 54-bit approximation and round that.
- deleted 13y ago[deleted]