6 ms·
Yep, exactly. NAN's truly are a great example of just how weird an edge case can get too! #define isNan(X) ((X) != (X))
by spyrja 1y ago
Yep, exactly. NAN's truly are a great example of just how weird an edge case can get too!
#define isNan(X) ((X) != (X))
- metadat 1y agoFor anyone else who forgot this or is unfamiliar with why / how it "works": > #define isNan(X) ((X) != (X)) > Works by exploiting a unique property of NaN (Not a Number) values in the IEEE-754 floating point standard: a NaN is not equal to itself. In other words, if you compare a floating-point variable to itself and the result is false ((X) != (X)(X)!=(X)), then X X is NaN. Fantastic example, thank you @spyrja!