2 ms·
Technically, addition is mostly commutative (a phrase I just made up) in IEEE 754. On the one hand, we have: NaN + 1 = NaN 1 + NaN = NaN but we also have:
by Someone 8y ago
Technically, addition is mostly commutative (a phrase I just made up) in IEEE 754. On the one hand, we have:
NaN + 1 = NaN
1 + NaN = NaN
but we also have:
NaN ≠ NaN
, so that’s an example where
a + b ≠ b + a
- BeetleB 8y agoHeh. You got me thinking on that one! I do know that with the floating point standard, NaN ≠ NaN returns True. But what does it mandate for NaN == NaN? Is this always false? If so, you're right. If not, I'd argue I'm still right, as that means that NaN + 1 == 1 + NaN would still be true.