Name

isnormal

Synopsis

Tests whether a given floating-point value is normalized

#include <math.h>
intisnormal( float x );
int isnormal( double x );
int isnormal( long double x );

The macro isnormal() yields a nonzero value (that is, true) if its argument’s value is a normalized floating-point number. Otherwise, isnormal() 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 maximum( double a, double b )
{
  if (isnormal( a ) && isnormal( b ) )    // Handle normal case first.
    return ( a >= b ) ? a : b ;

  else if ( isnan( a ) || isnan( b ) )
  {
    /* ... */

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.