Important: The information in this document is obsolete and should not be used for new development.
pow
You can use thepow
function to raise a real number to the power of some other real number.
double_t pow (double_t x, double_t y);
x
- Any floating-point number.
y
- Any floating-point number.
DESCRIPTION
Thepow
function computesx
to they
power. This is an ANSI standard C library function.
Use the function call
pow(x,y)
instead of the expression
exp(y * log(x))The callpow(x,y)
produces a more exact result.There are some differences between this implementation and the behavior of the
pow
function in a SANE implementation. For example, in SANEpow(NAN,0)
returns a NaN, whereas in PowerPC Numerics,pow(NAN,0)
returns a 1.EXCEPTIONS
When x and y are finite and nonzero, either the result of is exact or it raises one of the following exceptions:
- inexact (if y is not an integer or an underflow or overflow occurs)
- invalid (if x is negative and y is not an integer)
- overflow (if the result is outside the range of the data type)
- underflow (if the result is inexact and must be represented as a denormalized number or 0)
SPECIAL CASES
Table 10-11 shows the results when one of the arguments to thepow
function is a zero, a NaN, or an Infinity, plus other special cases for thepow
function. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the pow
functionOperation Result Exceptions raised for x < 0 NaN if y is not integer Invalid if y is integer None \xB10 if y is odd integer > 0 None +0 if y > 0 but not odd integer None \xB1 if y is odd integer < 0 Divide-by-zero + if y < 0 but not odd integer Divide-by-zero +1 None \xB10 if y is odd integer > 0 None +0 if y > 0 but not odd integer None \xB1 if y is odd integer < 0 Divide-by-zero + if y < 0 but not odd integer Divide-by-zero +1 None NaN if y 0 None[32] +1 if y = 0 None[32] NaN None[32] + if y > 0 None +0 if y < 0 None +1 if y = 0 None + if |x| > 1 None +0 if |x| < 1 None NaN if |x| = 1 Invalid if y is odd integer > 0 None + if y > 0 but not odd integer None if y is odd integer < 0 None +0 if y < 0 but not odd integer None +1 if y = 0 None +0 if |x| > 1 None + if |x| < 1 None NaN if |x| = 1 Invalid EXAMPLES
z = pow(NAN, 0); /* z = 1 */
[32] If the NaN is a signaling NaN, the invalid exception is raised.