HP-UX Floating-Point Guide

136 Chapter 5
Manipulating the Floating-Point Status Register
Run-Time Mode Control: The fenv(5) Suite
If you run this program, it generates the following output:
$ cc fe_flags.c -lm
$ ./a.out
at start:
no exceptions are set
after raising divide-by-zero exception:
division by zero occurred
after raising inexact exception:
inexact result occurred
division by zero occurred
after clearing exceptions:
no exceptions are set
after raising underflow exception:
inexact result occurred
underflow occurred
after fesetexceptflag:
no exceptions are set
Manipulating the Exception Trap Enable Bits:
fegettrapenable and fesettrapenable
The fegettrapenable function retrieves the current setting of the
exception trap enable bits. The fesettrapenable function sets the trap
enable bits.
The C declarations for these functions are as follows:
int fegettrapenable(void);
void fesettrapenable(int excepts);
The fegettrapenable function returns the bitwise OR of the exception
macros corresponding to the currently set exception trap enable bits.
The fesettrapenable function sets the exception trap enable bits
indicated by the argument excepts, which is a bitwise OR of the exception
macros corresponding to the desired exception trap enable bits. The
function also clears the trap enable bits for any exceptions not indicated
by the argument excepts.
The following program calls these functions.