Node:Floating Point Classes, Next:Floating Point Errors, Previous:Floating Point Numbers, Up:Arithmetic
ISO C99 defines macros that let you determine what sort of floating-point number a variable holds.
int fpclassify (float-type x) | Macro |
This is a generic macro which works on all floating-point types and
which returns a value of type int . The possible values are:
|
fpclassify
is most useful if more than one property of a number
must be tested. There are more specific macros which only test one
property at a time. Generally these macros execute faster than
fpclassify
, since there is special hardware support for them.
You should therefore use the specific macros whenever possible.
int isfinite (float-type x) | Macro |
This macro returns a nonzero value if x is finite: not plus or
minus infinity, and not NaN. It is equivalent to
(fpclassify (x) != FP_NAN && fpclassify (x) != FP_INFINITE) isfinite is implemented as a macro which accepts any
floating-point type.
|
int isnormal (float-type x) | Macro |
This macro returns a nonzero value if x is finite and normalized.
It is equivalent to
(fpclassify (x) == FP_NORMAL) |
int isnan (float-type x) | Macro |
This macro returns a nonzero value if x is NaN. It is equivalent
to
(fpclassify (x) == FP_NAN) |
int isinf (double x) | Function |
int isinff (float x) | Function |
int isinfl (long double x) | Function |
This function returns -1 if x represents negative infinity,
1 if x represents positive infinity, and 0 otherwise.
|
int isnan (double x) | Function |
int isnanf (float x) | Function |
int isnanl (long double x) | Function |
This function returns a nonzero value if x is a "not a number"
value, and zero otherwise.
Note: The isnan macro defined by ISO C99 overrides
the BSD function. This is normally not a problem, because the two
routines behave identically. However, if you really need to get the BSD
function for some reason, you can write
(isnan) (x) |
int finite (double x) | Function |
int finitef (float x) | Function |
int finitel (long double x) | Function |
This function returns a nonzero value if x is finite or a "not a number" value, and zero otherwise. |
double infnan (int error) | Function |
This function is provided for compatibility with BSD. Its argument is
an error code, EDOM or ERANGE ; infnan returns the
value that a math function would return if it set errno to that
value. See Math Error Reporting. -ERANGE is also acceptable
as an argument, and corresponds to -HUGE_VAL as a value.
In the BSD library, on certain machines, infnan raises a fatal
signal in all cases. The GNU library does not do likewise, because that
does not fit the ISO C specification.
|