The IBM Developer's Toolkit for OS/2 Warp Version 4 compiler supports the use of infinity and NaN (not-a-number) values. Infinity is a value with an associated sign that is mathematically greater in magnitude than any binary floating-point number. A NaN is a value in floating-point computations that is not interpreted as a mathematical value, and that contains a mask state and a sequence of binary digits.
The value of infinity can be computed from 1.0 / 0.0. The value of a NaN can be computed from 0.0 / 0.0.
Depending on its bit pattern, a NaN can be either quiet (NaNQ) or signaling (NaNS), as defined in the ANSI/IEEE Standard for Binary Floating-Point Arithmetic (754-1982). A NaNQ is masked and never generates exceptions. A NaNS may be masked and may generate an exception, but does not necessarily do so. The Developer's Toolkit for OS/2 Warp Version 4 compiler supports only quiet NaN values; all NaN values discussed below refer to quiet NaNs.
NaN and infinity values are defined as macro constants in the <float.h>
header file. The macros are: compact break=fit.
Macro
_INFINITYF
Description
You can get the corresponding negative values by using the unary minus operator (for example, -_INF).
Note: The value of 0.0 can also be positive or negative. For example, 1.0 / (-0.0) results in -_INF.
Because these macros are actually references to constant variables, you cannot use them to initialize static variables. For example, the following statements are not allowed:
static double infval = _INF; static float nanval = 1.0 + _NANF;However, you can initialize static variables to the numeric values of infinity and NaN:
static double infval = 1.0 / 0.0; static float nanval = 0.0 / 0.0;
Note: Although positive and negative infinities are specific bit patterns, NaNs are not. A NaN value is not equal to itself or to any other value. For example, if you assign a NaN value to a variable x, you cannot check the value of x with the statement if (_NAN == x). Instead, use the statement if (x != x).
All relational and equality expressions involving NaN values always evaluate to FALSE or zero (0), with the exception of not equal (!=), which always evaluates to TRUE or one (1).
For information on the bit mapping and storage mapping of NaN and infinity values, see the User's Guide.