C++ cmath exp() function
Example
Return e raised to the power of different numbers:
cout << exp(0);
cout << exp(1);
cout << exp(10);
cout << exp(4.8);
cout << exp(2.718);
Try it Yourself »
Definition and Usage
The exp()
function returns the result of e raised to the power of a number (ex).
The exp()
function is defined in the <cmath>
header file.
e is the base of the natural system of logarithms (approximately 2.718282). Some implementations of the <cmath>
library include a constant M_E
but it is not guaranteed to be available.
Syntax
One of the following:
exp(double number);
exp(float number);
Parameter Values
Parameter | Description |
---|---|
number |
Required. Specifies the power to which e is raised. If the number is an integer type then it will be treated as a double .
|
Technical Details
Returns: | A float value (if the argument is float) or double value (in any other case) representing the result of e to the power of a number. |
---|