exp()
is a dart:math
package function that returns the natural exponent, , to the power of a specified number.
The syntax of the exp()
method is as follows:
double exp(num x)
num x
: A mandatory numerical value that serves as the power to which the natural exponent, , is raised.exp()
returns the natural exponent, , raised to the power of x
. The result is returned as a double
.
exp()
returns NaN
(Not-A-Number) if x
is also NaN
.
In the code below, we will demonstrate the use of the exp()
method:
// Importing the dart math packageimport "dart:math";// Main functionvoid main(){// Not NaN values or real valuesdouble no1 = 4.00; // Real Numberdouble no2 = 100.00; // Real Numberdouble no3 = 3.50; // Real Number// NaN Valuesdouble no4 = 0/0; // NaNdouble no5 = pow(-2, 0.5); // NaN// Print values returned by the exp() functionprint(exp(no1));print(exp(no2));print(exp(no3));print(exp(no4));print(exp(no5));}
In the code above, we call the exp()
method with both numerical and NaN
arguments.
The function calls to the exp()
method in lines return the value of the natural exponent, , raised to the power of the provided parameter.
On the other hand, the function calls in lines provide NaN
as the argument, so the exp()
method also returns NaN
.