HP-UX Floating-Point Guide

Chapter 4 105
HP-UX Math Libraries on HP 9000 Systems
Math Library Basics
Figure 4-2 C Math Library Error Handling for the acos Function
If a C library function such as acos encounters an invalid argument, it
ordinarily returns a default result that indicates a failure—a result that
the function could not ordinarily return. The default result is usually a
NaN or HUGE_VAL, depending on the function and the argument value.
The function also commonly sets the invalid operation exception flag in
the floating-point status register. See “Handling Invalid Operation
Exceptions (C and Fortran)” on page 106 for details.
In addition, some functions set the global value errno, defined in the
header file errno.h. (Many HP-UX system calls also set this value.)
When a library call fails, the value of errno may be set to an appropriate
code, also defined by errno.h. The math library functions set errno to
either EDOM or to ERANGE. EDOM indicates a domain error—that is, an
error in the argument. ERANGE indicates a range error—usually an
overflow in the result.