HP-UX Floating-Point Guide
Chapter 4 103
HP-UX Math Libraries on HP 9000 Systems
Math Library Basics
Step A
The compiler-generated call to a math library function includes code that
• Converts the argument to the required format, if necessary
• Places the argument in the appropriate place (that is, where the
function expects it)
• Calls the function
Step B
The function determines whether the argument is valid. All functions
check for NaN arguments and make additional checks specific to the
function. For example, a logarithmic function checks for negative or zero
arguments; an exponential function checks to see if the argument is so
large that the result would overflow. If the argument is valid, control
passes to Step C, execution of the function. If the argument is not valid,
control passes to Step D.
Step C
The execution of the function involves performing the appropriate
transformation on the argument(s). For most math functions, the result
has the same data type as the argument, which is usually
double-precision.
The execution of the function actually consists of one of many possible
paths through the function code. The nature of the argument usually
determines the path taken. For example, there may be special paths for
particular argument ranges, or there may be an argument reduction
phase. Math library implementors tune the most frequently executed
paths for optimal efficiency. Consequently, arguments that are unusual
(for example, very large or very small) can cause noticeable performance
degradation.
Step D
If an argument proves to be invalid, control may pass to the
error-handling function of the library. When this happens, performance
may slow considerably; it can be 2 to 3 orders of magnitude slower than
for a valid argument. This follows from the basic assumption in math
library design that errors are rare events.