# C <math.h> - FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL

The C <math.h> FP_NORMAL, FP_SUBNORMAL, FP_ZERO, FP_INFINITE, FP_NAN macros represents distinct category of floating-point numbers and possible values returned by fpclassify function. These macros expand to an integer constant expression.

MacrosDescription
FP_NAN indicates that the value is not-a-number (NaN).
FP_INFINITE indicates that the value is positive or negative infinity (overflow).
FP_ZERO indicates that the value is positive or negative zero.
FP_SUBNORMAL indicates that the value is subnormal (underflow).
FP_NORMAL indicates that the value is normal, i.e. not an infinity, subnormal, not-a-number or zero.

Definition in the <cmath> header file is:

```#define FP_NAN       /*implementation defined*/
#define FP_INFINITE  /*implementation defined*/
#define FP_ZERO      /*implementation defined*/
#define FP_SUBNORMAL /*implementation defined*/
#define FP_NORMAL    /*implementation defined*/
```

### Example:

The example below shows the usage of these macros.

```#include <stdio.h>
#include <float.h>
#include <math.h>

const char* Show_Classification (double x) {
switch(fpclassify(x)) {
case FP_NAN:
return "nan.";
case FP_INFINITE:
return "inf.";
case FP_ZERO:
return "zero.";
case FP_SUBNORMAL:
return "subnormal.";
case FP_NORMAL:
return "normal.";
default:
return "unknown.";
}
}

int main (){
printf("1.0/0.0 is %s\n", Show_Classification(1.0/0.0));
printf("0.0/0.0 is %s\n", Show_Classification(0.0/0.0));
printf("DBL_MIN/3 is %s\n", Show_Classification(DBL_MIN/3));
printf("-0.0 is %s\n", Show_Classification(-0.0));
printf("10.5 is %s\n", Show_Classification(10.5));
return 0;
}
```

The output of the above code will be:

```1.0/0.0 is inf.
0.0/0.0 is nan.
DBL_MIN/3 is subnormal.
-0.0 is zero.
10.5 is normal.
```

❮ C <math.h> Library

5