template < typename FloatType >
inline const bool is_NaN( FloatType number )
{
// A NaN doesn't compare equal to anything, not even itself.
return number != number;
}
Obviously, I intend to use this to test a floating point variable for NaN (not a number) ... can't use std::isnan() because our compiler doesn't support C++11. My worry is that the compiler might optimize the whole call away, on account of comparing a number to itself being so unbelievably stupid.