HP-UX Floating-Point Guide

Chapter 2 53
Floating-Point Principles and the IEEE Standard for Binary Floating-Point Arithmetic
Exception Conditions
Exception Conditions
The IEEE standard defines five exception conditions, also called
exceptions:
Inexact result
Overflow
Underflow
Invalid operation
Division by zero
The following sections describe the exceptions.
On HP-UX systems, traps for all of these exceptions are initially disabled
by default. You can enable traps for some or all of these exceptions by
using the fesettrapenable function, the +T option (f77 only), the
+fp_exception option (f90 only), or the +FP compiler option. For more
information, see “Enabling Traps” on page 153.
The standard requires that a conforming implementation provide
exception flags (see “The PA-RISC Floating-Point Status Register” on
page 128). If an exception occurs and a trap for the exception is not
enabled, the corresponding exception flag is set.
NOTE The IEEE standard defines the conditions under which exceptions occur
only for the basic operations (see “Floating-Point Operations” on
page 61). Exceptions for more complicated operations, such as
trigonometric and transcendental functions, can vary depending on what
compiler options you specified when compiling the program. For more
information on exception handling, see “Math Library Basics” on
page 101 and Chapter 6.
Inexact Result (Rounding)
As we explained in “Floating-Point Formats and the Limits of IEEE
Representation” on page 40, all computer floating-point systems are
inherently inexact because they cannot represent all values. When a
computer system cannot represent a number exactly, it must choose a
nearby representable value. This is called rounding, and it always