Determines classifications of floating-point numbers.
IEEE Math Library (libm.a) or System V Math Library (libmsaa.a)
The class subroutine, _class subroutine, finite subroutine, isnan subroutine, and unordered subroutine determine the classification of their floating-point value. The unordered subroutine determines if a floating-point comparison involving x and y would generate the IEEE floating-point unordered condition (such as whether x or y is a NaN).
The class subroutine returns an integer that represents the classification of the floating-point x parameter. Since class is a reversed key word in C++. The class subroutine can not be invoked in a C++ program. The _class subroutine is an interface for C++ program using the class subroutine. The interface and the return value for class and _class subroutines are identical. The values returned by the class subroutine are defined in the float.h header file. The return values are the following:
Item | Description |
---|---|
FP_PLUS_NORM | Positive normalized, nonzero x |
FP_MINUS_NORM | Negative normalized, nonzero x |
FP_PLUS_DENORM | Positive denormalized, nonzero x |
FP_MINUS_DENORM | Negative denormalized, nonzero x |
FP_PLUS_ZERO | x = +0.0 |
FP_MINUS_ZERO | x = -0.0 |
FP_PLUS_INF | x = +INF |
FP_MINUS_INF | x = -INF |
FP_NANS | x = Signaling Not a Number (NaNS) |
FP_NANQ | x = Quiet Not a Number (NaNQ) |
Since class is a reserved keyword in C++, the class subroutine cannot be invoked in a C++ program. The _class subroutine is an interface for the C++ program using the class subroutine. The interface and the return values for class and _class subroutines are identical.
The finite subroutine returns a nonzero value if the x parameter is a finite number; that is, if x is not +-, INF, NaNQ, or NaNS.
The isnan subroutine returns a nonzero value if the x parameter is an NaNS or a NaNQ. Otherwise, it returns 0.
The unordered subroutine returns a nonzero value if a floating-point comparison between x and y would be unordered. Otherwise, it returns 0.
cc class.c -lm
Item | Description |
---|---|
x | Specifies some double-precision floating-point value. |
y | Specifies some double-precision floating-point value. |
The finite, isnan, and unordered subroutines neither return errors nor set bits in the floating-point exception status, even if a parameter is an NaNS.