Remix.run Logo
adastra22 10 hours ago

It is not, due to precision. Consider a=1.00000, b=-0.99999, and c=0.00000582618.

jcranmer 9 hours ago | parent | next [-]

No, the two evaluations will give you exactly the same result: https://play.rust-lang.org/?version=stable&mode=debug&editio...

IEEE 754 operations are nonassociative, but they are commutative (at least if you ignore the effect of NaN payloads).

dbdr an hour ago | parent [-]

Is there a case involving NaN where they are not commutative? Do you mean getting a different bit-level representation of NaN?

Remnant44 11 minutes ago | parent [-]

In practical use for simd, various min/max operations. On Intel at least, they propagate nan or not based on operand order

zygentoma 10 hours ago | parent | prev | next [-]

You still need to specify an evaluation order …

immibis 9 hours ago | parent | prev [-]

Does (1.00000+-0.99999)+0.00000582618 != 0.00000582618+(-0.99999+1.00000) ? This would disprove commutativity. But I think they're equal.