HP-UX Floating-Point Guide
Chapter 5 133
Manipulating the Floating-Point Status Register
Run-Time Mode Control: The fenv(5) Suite
The C library supplies a group of functions, all included in the C9X draft
standard, to manipulate the exception flags. The library also supplies
two functions, not included in the C9X draft standard and specific to HP,
to manipulate the exception trap enable bits. The following subsections
discuss these groups of functions.
The functions use the following exception macros, defined in fenv.h, for
the exception flags and the exception trap enable bits:
FE_INEXACT Inexact result
FE_UNDERFLOW Underflow
FE_OVERFLOW Overflow
FE_DIVBYZERO Divide by zero
FE_INVALID Invalid operation
FE_ALL_EXCEPT All exceptions
For details about using these functions to detect and handle
floating-point exceptions, see “Using the fesettrapenable Function” on
page 154 and “Detecting Exceptions without Enabling Traps” on
page 164.
Manipulating the Exception Flags: fegetexceptflag,
fesetexceptflag, fetestexcept, feraiseexcept,
feclearexcept
The functions fegetexceptflag and fetestexcept return the
current settings of the exception flags. The fesetexceptflag function
sets the flags to a previously saved state. The feraiseexcept function
raises exceptions, and the feclearexcept function clears the exception
flags.
The C declarations for these functions are as follows:
void fegetexceptflag(fexcept_t *flagp, int excepts);
void fesetexceptflag(const fexcept_t *flagp, int excepts);
int fetestexcept(int excepts);
void feraiseexcept(int excepts);
void feclearexcept(int excepts);
The fegetexceptflag function stores the desired exception flags (as
indicated by the argument excepts, which can be any bitwise OR of the
exception macros) in the object pointed to by the argument flagp.