C Math expm1() Function
Example
Return e to the power of x, minus 1:
printf("%f\n", expm1(0));
printf("%f", expm1(1));
Definition and Usage
The expm1() function returns ex - 1, where e is Euler's number (about 2.71828).
It gives the same result as exp(x) - 1, but it is more precise when x is very close to 0.
The expm1() function is defined in the <math.h> header file.
Tip: log1p() does the opposite. To get ex without the minus 1, use exp().
Syntax
double expm1(double x);
There are also versions for float and long double values: expm1f() and expm1l().
Parameter Values
| Parameter | Description |
|---|---|
| x | Required. The power to raise e to. |
Technical Details
| Returns: | A double value with ex - 1. |
|---|
Related Pages
Read more about math in our C Math Tutorial.