| 
 Tests whether a given floating-point value is "not a number" #include <math.h> int isnan ( float x ); int isnan ( double x ); int isnan ( long double x ); The macro isnan( ) yields a nonzero value (that is, TRue) if its argument is a NaN, or "not a number" (see the section on float.h in Chapter 15). Otherwise, isnan( ) yields 0. The argument must be a real floating-point type. The rule that floating-point types are promoted to at least double precision for mathematical calculations does not apply here; the argument's properties are determined based on its representation in its actual semantic type. Example
double dMax( double a, double b )
{
  // NaN overrides all comparison:
  if ( isnan( a ) ) return a;
  if ( isnan( b ) ) return b;
  // Anything is greater than -inf:
  if ( isinf( a ) && signbit( a ) ) return b;
  if ( isinf( b ) && signbit( b ) ) return a;
  return ( a > b ? a : b );
}
See Alsofpclassify( ), isfinite( ), isinf( ), isnormal( ), signbit( ) |