HP-UX Floating-Point Guide

104 Chapter 4
HP-UX Math Libraries on HP 9000 Systems
Math Library Basics
A math library call that encounters an illegal argument does some or all
of the following, depending on which programming language you are
using, whether traps are enabled, and which standards are being
enforced:
1. Supplies a system-defined default result: NaN for invalid operations,
a huge value for overflows, and so on
2. Sets the globally accessible error code variable errno
3. Sets some state in the hardware floating-point status register
4. Prints an error message to stderr
5. Returns to the calling application, returning the default result
Your program may cause any of the above steps to be modified or
stopped. “Math Library Error Handling for C” on page 104 describes how
these steps are performed for the C programmer; “Math Library Error
Handling for Fortran” on page 106 describes how they are performed for
the Fortran programmer. Users of other languages should refer to the
appropriate language manual for details.
Step E
When the function exits, the compiler-generated call to the function
passes the result from where the function left it to where it is needed,
converting it to the required format if necessary.
Math Library Error Handling for C
Error handling for the C math library follows the XPG4.2 specification,
which is a superset of the ANSI C standard.
The flowchart in Figure 4-2 summarizes the error handling in the C
math library. We use the acos function as an example.