FP_NORMAL, FP_SUBNORMAL, FP_ZERO, FP_INFINITE, FP_NAN

From cppreference.com
< c‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
(C99)
(C99)
(C99)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
(C99)(C99)(C99)
(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
Macro constants
FP_NORMALFP_SUBNORMALFP_ZEROFP_INFINITEFP_NAN
(C99)(C99)(C99)(C99)(C99)
 
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

#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

classifies the given floating-point value
(function)
C++ documentation for FP_categories