HP-UX Floating-Point Guide
Chapter 4 115
HP-UX Math Libraries on HP 9000 Systems
Contents of the HP-UX Math Libraries
• Compile with the basic ANSI option -Aa and use the -D option to
define the macro _HPUX_SOURCE on the command line. If this macro
is defined, all the function declarations are visible. (If you compile
with -Ae or -Ac, this macro is defined automatically.)
cc -Aa -D_HPUX_SOURCE program_name.c -lm
ANSI mode is the default for the HP C++ compilers (CC and aCC).
For a complete list of the contents of libm, see Appendix A. The
functions are described in online man pages.
float Type Math Functions
Certain libm math functions are implemented as single-precision
functions, accepting float arguments and returning a float result. On
HP 9000 systems, the performance of single-precision and
double-precision functions is similar. If your application uses
single-precision data types heavily, you may find it convenient to use the
float versions of the math functions the application calls.
The names of the float functions are the same as those of their
double-precision counterparts but with the letter f appended. (For
float versions of degree-valued trigonometric functions, the f follows
the d.) This naming convention accords with that specified in Section
4.13 of the ANSI C standard, “Future Library Directions.”
The supplied functions are as follows:
• cosf, sinf, tanf, cosdf, sindf, tandf
• acosf, asinf, atanf, atan2f, acosdf, asindf, atandf, atan2df
• coshf, sinhf, tanhf
• expf, fabsf, fmodf, logf, log10f, log2f, powf, sqrtf, cbrtf
• copysignf, nextafterf
You must compile in ANSI mode (with -Ae, the default, or with -Aa
-D_HPUX_SOURCE) to use these functions. If you compile in ANSI mode,
ANSI C rules are followed, and the argument is treated as a float
throughout the function call. If you do not compile in ANSI mode,
traditional K&R C rules are followed, the compiler generates code to