6.11.77 fpclassify Macro
Classifies its argument as one of several floating-point categories.
Include
<math.h>
Prototype
int fpclassify(floating-point
x);
Argument
x
- any floating-point number
Return Value
Classifies its argument as one of several floating-point categories, such as NaN, infinite, normal, subnormal, zero, or as another implementation-defined category, represented by the floating-point classification macros discussed in Floating-point Classification Macros.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x;
int b;
x = 0.0;
b = fpclassify(x);
if(b == FP_ZERO)
printf("The value %f has been classified as a floating-point zero\n", x);
}
Example Output
The value 0.000000 has been classified as a floating-point zero