fpclassify, isfinite, isnormal, isnan, isinf - floating-point classification macros
#include <math.h>
int fpclassify(x);
int isfinite(x);
int isnormal(x);
int isnan(x);
int isinf(x);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
Floating point numbers can have special values, such as infinite or
NaN. With the macro
fpclassify(x
) you can find
out what type x
is. The macro takes any floating-point
expression as argument. The result is one of the following values:
x
is "Not a Number".
x
is either positive infinity or negative infinity.
x
is zero.
x
is too small to be represented in normalized format.
if nothing of the above is correct then it must be a normal floating-point number.
The other macros provide a short answer to some standard questions.
x
)returns a nonzero value if
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
x
)returns a nonzero value if (fpclassify(x) == FP_NORMAL)
x
)returns a nonzero value if (fpclassify(x) == FP_NAN)
x
)returns 1 if x
is positive infinity, and -1 if x
is
negative infinity.