isNan is defined like this in iOS SDK, math.h as below,
#define isnan(x) \
( sizeof(x) == sizeof(float) ? __inline_isnanf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isnand((double)(x)) \
: __inline_isnanl((long double)(x)))
And the inline function goes like this,
__header_always_inline int __inline_isnanf(float __x) {
return __x != __x;
}
__header_always_inline is just to force the compiler to make the function surely inline.
What actually has been done in the inline function is pretty evasive to my eyes.
return __x != __x;
What does this line do? How does it verify if the argument is a NaN or not?
Edit:
The question here is NOT why NaN is not equal to NaN; but how its implemented. So please guide your answers towards the actual low level implementation.
Any help is greatly appreciated. Thanks.