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


exp2

You can use the exp2 function to raise 2 to some power.

double_t exp2 (double_t x);
x
Any floating-point number.
DESCRIPTION
The exp2 function returns the base 2 exponential of its argument.

exp2(x) = 2x

The log2 function performs the inverse operation log22x) .

EXCEPTIONS
When x is finite and nonzero, the result of exp2(x) might raise the following exceptions:

  • inexact (for all finite, nonzero values of x)
  • 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-8 shows the results when the argument to the exp2 function is a zero, a NaN, or an Infinity.
Special cases for the exp2 function
OperationResultExceptions raised
exp2(+0) +1None
exp2(-0) +1None
exp2(NaN) NaNNone[29]
exp2(+ ) + None
exp2(- ) +0None

EXAMPLES
z = exp2(2.0); /* z = 22 = 4. The inexact exception is raised. */
z = exp2(1.5); /* z = 21.5  2.82843. The inexact exception is 
                  raised. */

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

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996