C examples for math.h:fpclassify
macro/function
<cmath> <ctgmath> <math.h>
Returns a value of type int that matches one of the classification macro constants, depending on the value of x:
value | description |
---|---|
FP_INFINITE | Positive or negative infinity (overflow) |
FP_NAN | Not-A-Number |
FP_ZERO | Value of zero |
FP_SUBNORMAL | Sub-normal value (underflow) |
FP_NORMAL | Normal value (none of the above) |
int fpclassify (float x); //function int fpclassify (double x);//function int fpclassify (long double x);//function fpclassify(x)//macro
Parameter | Description |
---|---|
x | The value to classify. |
One of the following int values:
#include <stdio.h> #include <math.h> int main()/* w w w .j a v a2s .c o m*/ { int a = 0; double d = 1.0 / a; switch (fpclassify(d)) { case FP_INFINITE: printf ("infinite"); break; case FP_NAN: printf ("NaN"); break; case FP_ZERO: printf ("zero"); break; case FP_SUBNORMAL: printf ("subnormal"); break; case FP_NORMAL: printf ("normal"); break; } return 0; }