Next: , Previous: infinity, Up: Math


1.24 isnan, isnanf, isinf, isinff, finite, finitef—test for exceptional numbers

Synopsis

     #include <ieeefp.h>
     int isnan(double arg);
     int isinf(double arg);
     int finite(double arg);
     int isnanf(float arg);
     int isinff(float arg);
     int finitef(float arg);
     

Description
These functions provide information on the floating-point argument supplied.

There are five major number formats:

zero
A number which contains all zero bits.
subnormal
A number with a zero exponent but a nonzero fraction.
normal
A number with an exponent and a fraction.
infinity
A number with an all 1's exponent and a zero fraction.
NAN
A number with an all 1's exponent and a nonzero fraction.

isnan returns 1 if the argument is a nan. isinf returns 1 if the argument is infinity. finite returns 1 if the argument is zero, subnormal or normal. The isnanf, isinff and finitef functions perform the same operations as their isnan, isinf and finite counterparts, but on single-precision floating-point numbers.

It should be noted that the C99 standard dictates that isnan and isinf are macros that operate on multiple types of floating-point. The SUSv2 standard declares isnan as a function taking double. Newlib has decided to declare them both as macros in math.h and as functions in ieeefp.h.