HP-UX Floating-Point Guide
60 Chapter 2
Floating-Point Principles and the IEEE Standard for Binary Floating-Point Arithmetic
Exception Processing
Exception Processing
Exception processing refers to the sequence of events that takes place
when any of the IEEE exception conditions occur. The standard states
that a programmer should be able to enable or disable the trapping of
any of the exception conditions. The standard also defines default results
for all disabled exceptions. For example, Table 2-11 on page 57 shows
how a default result is formulated when an overflow occurs and overflow
traps are disabled.
The standard also states that a programmer should be able to define a
trap handler for each exception condition. The trap handler (also called
a signal handler) is a routine that is invoked whenever the particular
exception condition is detected, assuming that trapping for the exception
is enabled. If a program enables trapping but provides no trap handler, a
default handler will be invoked that prints an error message and causes
the process to terminate.
As we noted in “Exception Conditions” on page 53, all traps are disabled
by default on HP-UX systems. You can use the fesettrapenable
function, described in “Run-Time Mode Control: The fenv(5) Suite” on
page 127, to enable any traps you want to handle. You can also enable
traps through compiler options, which we discuss in “Command-Line
Mode Control: The +FP Compiler Option” on page 148.
On HP-UX systems, the methods for establishing trap handlers for the
IEEE-754 exceptions are the sigaction(2) routine for C programs and the
ON statement for Fortran programs. See “Math Library Basics” on
page 101 and “Handling Traps” on page 157 for more information.