7.3 The <fp.h> Header File

The <fp.h> header file implements some of the features defined by the Numerical C Extensions Group of the ANSI X3J11 committee. You might find this useful for applications that make extensive use of floating-point functions.

Some of the double-precision functions listed in this chapter return the value ħHUGE_VAL (defined in either <math.h> or <fp.h>) if the result is out of range. The float version of those functions return the value HUGE_VALF (defined only in <fp.h>) for the same conditions. The long double version returns the value HUGE_VALL (also defined in <fp.h>).

For programs compiled to enable IEEE infinity and NaN values, the values HUGE_VAL, HUGE_VALF, and HUGE_VALL are expressions, not compile-time constants. Initializations such as the following cause a compile-time error:

$ CREATE IEEE_INFINITY.C
#include <fp.h>

double my_huge_val = HUGE_VAL
^Z
$ CC /FLOAT=IEEE/IEEE=DENORM IEEE_INFINITY

double my_huge_val = HUGE_VAL;
.....................^
%CC-E-NEEDCONSTEXPR, In the initializer for my_huge_val, "decc$gt_dbl_infinity"
is not constant, but occurs in a context that requires a constant expression.
at line number 3 in file WORK1$:[RTL]IEEE_INFINITY.C;1
$

When using both <math.h> and <fp.h>, be aware that <math.h> defines a function isnan and <fp.h> defines a macro by the same name. Whichever header is included first in the application will resolve a reference to isnan.


Previous Page | Next Page | Table of Contents | Index