HP-UX Floating-Point Guide

Contents
7
4. HP-UX Math Libraries on HP 9000 Systems
HP-UX Library Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
Math Library Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
Anatomy of a Math Library Function Call . . . . . . . . . . . . . . . . . . . . .102
Math Library Error Handling for C . . . . . . . . . . . . . . . . . . . . . . . . . .104
Handling Invalid Operation Exceptions (C and Fortran) . . . . . . . . .106
Math Library Error Handling for Fortran . . . . . . . . . . . . . . . . . . . . .106
Contents of the HP-UX Math Libraries . . . . . . . . . . . . . . . . . . . . . . . . .112
Scalar Math Libraries (libm and libcl) . . . . . . . . . . . . . . . . . . . . . . . .112
The BLAS Library (libblas) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
The Vector Library (libvec) (Obsolete). . . . . . . . . . . . . . . . . . . . . . . . .121
Calling C Library Functions from Fortran. . . . . . . . . . . . . . . . . . . . . . .123
5. Manipulating the Floating-Point Status Register
Run-Time Mode Control: The fenv(5) Suite. . . . . . . . . . . . . . . . . . . . . .127
The PA-RISC Floating-Point Status Register. . . . . . . . . . . . . . . . . . .128
Rounding Mode: fegetround and fesetround. . . . . . . . . . . . . . . . . . . .130
Exception Bits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
Manipulating the Floating-Point Environment: fegetenv, fesetenv,
feupdateenv, feholdexcept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Underflow Mode: fegetflushtozero and fesetflushtozero. . . . . . . . . . .145
Command-Line Mode Control: The +FP Compiler Option . . . . . . . . . .148
6. Floating-Point Trap Handling
Enabling Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
Using the +FP Compiler Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
Using the fesettrapenable Function . . . . . . . . . . . . . . . . . . . . . . . . . .154
Using the +fp_exception or +T Compiler Option (Fortran only) . . . .155