C++ cmath expm1() Function
Example
Return e to the power of x, minus 1:
cout << expm1(0) << "\n";
cout << 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 <cmath> header file.
Tip: log1p() does the opposite. To get ex without the minus 1, use exp().
Syntax
expm1(double x)
The function also works with float and long double values. Then it returns a value of the same type.
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 Math Tutorial.