Hacker News new | ask | show | jobs
by metadat 299 days ago
For 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!