4 ms·
Is there a case involving NaN where they are not commutative? Do you mean getting a different bit-level representation of NaN?
by dbdr 11mo ago
Is there a case involving NaN where they are not commutative? Do you mean getting a different bit-level representation of NaN?
- Remnant44 11mo agoIn practical use for simd, various min/max operations. On Intel at least, they propagate nan or not based on operand order
- boulos 11mo agoAlso all comparisons.
- jcranmer 11mo agoIEEE 754 doesn't (usually) distinguish between different NaN encodings for the purposes of semantics--if the result is a NaN, it doesn't specify which NaN the result is. Most hardware vendors implement a form of NaN propagation: when both inputs are NaN, one of the operands is returned, for example, always the left NaN is returned if both are NaN. As a side note: all compilers I'm aware of make almost no guarantees on preserving the value of NaN payloads, hence they consider floating-point operations to be fully commutative, and there's no general way to guarantee that they evaluate in exactly the order you specified.