I can’t figure out whether I just don’t understand the following example from the Wikipedia page on floating point about the non-associativity of some FP operations, or if it is in error.
Here’s the page (the example is in the second shaded box below the page ref):
Accuracy Problems
Here’s the full example:
While floating-point addition and multiplication are both commutative (a + b = b + a and a×b = b×a), they are not necessarily associative. That is, (a + b) + c is not necessarily equal to a + (b + c). Using 7-digit decimal arithmetic:
1234.567 + 45.67844 = 1280.245
1280.245 + 0.0004 = 1280.245
but
45.67840 + 0.00004 = 45.67844
45.67844 + 1234.567 = 1280.246
Huh? I can’t tell what a, b, and c are supposed to be in the example.
My first guess was a=1234.567, b=45.67804, c=0.0004, but that doesn’t work for the second part of the problem.
Even so, the first part (1234.567 + 45.67844 = 1280.245) doesn’t even jibe with the last part (45.67844 + 1234.567 = 1280.246).
The only thing I can think of is that I don’t understand “7-digit decimal arithmetic,” but if that’s the case, I can’t for the life of me figure out what that means.