##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# FP_NORMAL, FP_SUBNORMAL, FP_ZERO, FP_INFINITE, FP_NAN

From cppreference.com
< c‎ | numeric‎ | math

Defined in header `<math.h>` |  |
#define FP_NORMAL /*implementation defined*/ |  | (since C99)
#define FP_SUBNORMAL /*implementation defined*/ |  | (since C99)
#define FP_ZERO /*implementation defined*/ |  | (since C99)
#define FP_INFINITE /*implementation defined*/ |  | (since C99)
#define FP_NAN /*implementation defined*/ |  | (since C99)

The `FP_NORMAL`, `FP_SUBNORMAL`, `FP_ZERO`, `FP_INFINITE`, `FP_NAN` macros each represent a distinct category of floating-point numbers. They all expand to an integer constant expression.

Constant | Explanation
`FP_NORMAL` | indicates that the value is normal, i.e. not an infinity, subnormal, not-a-number or zero
`FP_SUBNORMAL` | indicates that the value is subnormal
`FP_ZERO` | indicates that the value is positive or negative zero
`FP_INFINITE` | indicates that the value is not representable by the underlying type (positive or negative infinity)
`FP_NAN` | indicates that the value is not-a-number (NaN)

### [edit] Example

Run this code

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

    int main(void)
    {
        printf("FP_NAN       = %d\n", FP_NAN);         /* 0 */
        printf("FP_INFINITE  = %d\n", FP_INFINITE);    /* 1 */
        printf("FP_ZERO      = %d\n", FP_ZERO);        /* 2 */
        printf("FP_SUBNORMAL = %d\n", FP_SUBNORMAL);   /* 3 */
        printf("FP_NORMAL    = %d\n", FP_NORMAL);      /* 4 */

        return 0;
    }

Possible output:

    FP_NAN       = 0
    FP_INFINITE  = 1
    FP_ZERO      = 2
    FP_SUBNORMAL = 3
    FP_NORMAL    = 4

### [edit] See also

fpclassify (C99) | classifies the given floating-point value (function) [edit]
C++ documentation for FP_categories

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/numeric/math/FP_categories&oldid=70153"