>>> x = 7.00000000000001
>>> x + 1 - x
1.0000000000000009
>>> x - x + 1
1.0Subtraction is obviously not commutative, so let's rewrite as an addition.
x + 1 - x => x + 1 + (-x)
x - x + 1 => x + (-x) + 1
Now write the implicit parenthesis x + 1 + (-x) => (x + 1) + (-x)
x + (-x) + 1 => (x + (-x)) + 1
Now since we assumed addition is commutative, let swap a few things (x + 1) + (-x) => (-x) + (x + 1)
(x + (-x)) + 1 => ((-x) + x) + 1
And you get the classic associativity problem. If, by swapping things, we would have gotten the same expression, it would have been a contradiction, proving that addition was not commutative, but it is not the case here.It means that if addition is not associative, which we know is the case, then your example doesn't prove that addition is not commutative.
Of course, I didn't prove that in general, addition is commutative, but it has no reason not to be.
NaN + 1 <> 1 + NaN
(as NaN <> NaN)IIRC it also breaks down with signed zeros.