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


expm1

You can use the expm1 function to raise e to some power and subtract 1.

double_t expm1 (double_t x);
x
Any floating-point number.
DESCRIPTION
The expm1 function returns the natural exponential decreased by 1.

expm1(x) = ex+-1

For small numbers, use the function call expm1(x) instead of the expression

exp(x) - 1
The call expm1(x) produces a more exact result because it avoids the roundoff error that might occur when the expression is computed.

EXCEPTIONS
When x is finite and nonzero, the result of expm1(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-9 shows the results when the argument to the expm1 function is a zero, a NaN, or an Infinity.
Special cases for the expm1 function
OperationResultExceptions raised
expm1(+0) +0None
expm1(-0) -0None
expm1(NaN) NaNNone[30]
expm1(+ ) + None
expm1(- ) -1None

EXAMPLES
z = expm1(-2.1);     /* z = e-2.1 - 1 = -0.877544. The inexact
                        exception is raised. */
z = expm1(6);        /* z = e6 - 1 = 402.429. The inexact 
                        exception is raised. */

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

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996