The Math.Exp() method in C# is used to return e raised to the specified power.
Syntax
public static double Exp (double val);
Here, Val is the power.
If Val equals NaN or PositiveInfinity, that value is returned. However, if d equals NegativeInfinity, 0 is returned.
Let us now see an example to implement Math.Exp() method −
Example
using System;
public class Demo {
public static void Main(){
Console.WriteLine(Math.Exp(0.0));
Console.WriteLine(Math.Exp(Double.PositiveInfinity));
Console.WriteLine(Math.Exp(Double.NegativeInfinity));
}
}Output
This will produce the following output −
1 ∞ 0
Let us see another example to implement Math.Exp() method −
Example
using System;
public class Demo {
public static void Main(){
Console.WriteLine(Math.Exp(10.0));
Console.WriteLine(Math.Exp(Double.NaN));
}
}Output
This will produce the following output −
22026.4657948067 NaN