Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Exponential Functions


pow

You can use the pow 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
The pow function computes x to the y power. This is an ANSI standard C library function.

pow(x,y) = xy

Use the function call pow(x,y) instead of the expression

exp(y * log(x))
The call pow(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 SANE pow(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 pow(x,y) 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 the pow function is a zero, a NaN, or an Infinity, plus other special cases for the pow function. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the pow function
OperationResultExceptions raised
pow(x,y) for x < 0NaN if y is not integerInvalid
  xy if y is integerNone
pow(+0,y) \xB10 if y is odd integer > 0None
 +0 if y > 0 but not odd integerNone
 \xB1 if y is odd integer < 0Divide-by-zero
 + if y < 0 but not odd integerDivide-by-zero
pow(x,+0) +1None
pow(-0,y) \xB10 if y is odd integer > 0None
 +0 if y > 0 but not odd integerNone
 \xB1 if y is odd integer < 0Divide-by-zero
 + if y < 0 but not odd integerDivide-by-zero
pow(x,-0) +1None
pow(NaN,y) NaN if y 0None[32]
 +1 if y = 0None[32]
pow(x,NaN) NaNNone[32]
pow(+ ,y) + if y > 0None
 +0 if y < 0None
 +1 if y = 0None
pow(x,+ ) + if |x| > 1None
 +0 if |x| < 1None
 NaN if |x| = 1Invalid
pow(- ,y) - if y is odd integer > 0None
 + if y > 0 but not odd integerNone
  -0 if y is odd integer < 0None
 +0 if y < 0 but not odd integerNone
 +1 if y = 0None
pow(x,- ) +0 if |x| > 1None
 + if |x| < 1None
 NaN if |x| = 1Invalid

EXAMPLES
z = pow(NAN, 0);     /* z = 1 */

[32] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996