HP-UX Floating-Point Guide

74 Chapter 3
Factors that Affect the Results of Floating-Point Computations
How Exceptions and Library Errors Affect Application Results
How Exceptions and Library Errors
Affect Application Results
When an application performs a floating-point operation that causes an
exception condition or a library error, and the application is not coded to
detect and deal with the exception or error, the default
exception-handling response of the system may introduce a dramatic
amount of error into the continuing computation. The types of exception
conditions and errors that can have this effect are
Overflow conditions
Underflow conditions
Invalid operation conditions
Division by zero conditions
Library domain and range errors (EDOM and ERANGE)
“Exception Conditions” on page 53 describes the exception conditions.
Math library routines generate domain errors when they encounter
invalid arguments; they generate range errors when they overflow or
when they generate exact infinities from finite arguments.
Table 3-1 shows the effects of these exceptions and errors on typical
applications. In many cases, the effect of an exception or a library error
on a program is catastrophic: that is, the program continues, but the
results it produces are meaningless. A common exception to this rule is
an underflow condition. An underflow means that the value returned by
the operation is extremely small. In many cases—for example, if the
program is evaluating a function at the point where the function crosses
the X axis—a value that is very near zero is exactly what you want, so
that the occurrence of an underflow is actually a successful result. In
other cases an overflow may be an expected result. If, in the expression
1 + 1/f(x), f(x) overflows, then 1/f(x) is 0, and the expression
evaluates to 1, which may be a perfectly acceptable result.