Download Numerical Computation Guide

Transcript
The ex argument specifies the set of exceptions to which the call applies. It must be a
bitwise “or” of the values listed in the first column of TABLE 4-5. (These values are
defined in fenv.h.)
TABLE 4-5
Exception Codes for fex_set_handling
Value
Exception
FEX_INEXACT
inexact result
FEX_UNDERFLOW
underflow
FEX_OVERFLOW
overflow
FEX_DIVBYZERO
division by zero
FEX_INV_ZDZ
0/0 invalid operation
FEX_INV_IDI
infinity/infinity invalid operation
FEX_INV_ISI
infinity-infinity invalid operation
FEX_INV_ZMI
0*infinity invalid operation
FEX_INV_SQRT
square root of negative number
FEX_INV_SNAN
operation on signaling NaN
FEX_INV_INT
invalid integer conversion
FEX_INV_CMP
invalid unordered comparison
For convenience, fenv.h also defines the following values: FEX_NONE (no
exceptions), FEX_INVALID (all invalid operation exceptions), FEX_COMMON
(overflow, division by zero, and all invalid operations), and FEX_ALL (all
exceptions).
The mode argument specifies the exception handling mode to be established for the
indicated exceptions. There are five possible modes:
■
FEX_NONSTOP mode provides the IEEE 754 default nonstop behavior. This is
equivalent to leaving the exception’s trap disabled. (Note that unlike
ieee_handler, fex_set_handling allows you to establish nondefault
handling for certain types of invalid operation exceptions and retain IEEE default
handling for the rest.)
■
FEX_NOHANDLER mode is equivalent to enabling the exception’s trap without
providing a handler. When an exception occurs, the system transfers control to a
previously installed SIGFPE handler, if present, or aborts.
■
FEX_ABORT mode causes the program to call abort(3c) when the exception
occurs.
■
FEX_SIGNAL installs the handling function specified by the handler argument for
the indicated exceptions. When any of these exceptions occurs, the handler is
invoked with the same arguments as if it had been installed by ieee_handler.
Chapter 4
Exceptions and Exception Handling
97