HP-UX Reference (11i v2 04/09) - 3 Library Functions N-Z (vol 7)

p
pow(3M) pow(3M)
USAGE
To use these functions, compile either with the default
-Ae option or with the -Aa and
-D_HPUX_SOURCE
options.
To use (for Itanium-based systems)
poww(), powq(), pownw(), pownq()
, powllnw(),or
powllnq(), compile also with the -fpwidetypes
option.
To use any of these functions, make sure your program includes
<math.h>, and link in the math library
by specifying
-lm on the compiler or linker command line.
For more information, see the HP-UX Floating-Point Guide.
PA-RISC Only
Millicode versions of the
pow() function are available. Millicode versions of math library functions are
usually faster than their counterparts in the standard library. To use these versions, compile your pro-
gram with the +Olibcalls or the +Oaggressive optimization option.
For special cases, the millicode versions return the same values as their standard library counterparts,
but do not set errno. (See the RETURN VALUE section.)
RETURN VALUE
Itanium-base System
For Itanium-based systems, the
pow() function follows the C99 specification for special cases:
pow(±0,y) returns ±Inf and raises the divide-by-zero floating-point exception for y an odd integer < 0.
pow(±0,y) returns +Inf and raises the divide-by-zero floating-point exception for y<0 and not an odd
integer.
pow(±0,y) returns ±0 for y an odd integer > 0.
pow(±0,y) returns +0 for y>0 and not an odd integer.
pow(-1,±Inf) returns 1.
pow(+1,x) returns 1 for any x, even a NaN.
pow(x,±0) returns 1 for any x, even a NaN.
pow(x,y) returns a NaN and raises the invalid floating-point exception for finite x<0 and finite non-
integer y.
pow(x,-Inf) returns +Inf for |x|<1.
pow(x,-Inf) returns +0 for |x|>1.
pow(x,+Inf) returns +0 for |x|<1.
pow(x,+Inf) returns +Inf for |x|>1.
pow(-Inf,y) returns -0 for y an odd integer < 0.
pow(-Inf,y) returns +0 for y<0 and not an odd integer.
pow(-Inf,y) returns -Inf for y an odd integer > 0.
pow(-Inf,y) returns +Inf for y>0 and not an odd integer.
pow(+Inf,y) returns +0 for y<0.
pow(+Inf,y) returns +inf for y>0.
Otherwise, if either argument is a NaN, then
pow() returns a NaN.
pow() returns infinity in lieu of a value whose magnitude is too large, and raises the overflow and inex-
act exceptions.
pow() raises the underflow and inexact exceptions whenever a result is tiny (essentially denormal or
zero) and thereby suffers loss of accuracy, and may raise those exceptions if the result is merely tiny.
pow() raises the inexact exception whenever a rounded result does not equal the mathematical result.
Return values and errno settings for
pow() that match the PA-RISC behavior specified below can be
obtained on Itanium-based systems by compiling with the +Olibmerrno option.
The
pown() and powlln() functions follow the specification for the pow() function in the applicable
special and error cases.
Section 3726 Hewlett-Packard Company 2 HP-UX 11i Version 2: September 2004