C# | Math.Exp() Method
Last Updated :
01 Feb, 2019
In C#, Exp() is a Math class method which is used to return the e raised to the specified power. Here e is a mathematical constant whose value is approximately 2.71828. Exp() is the inverse of Log().
Syntax:
public static double Exp (double num);
Parameter:
num: It is the required number of type System.Double which specifies a power.
Return Type: It returns a number e raised to the power num of type System.Double.
Note:
- If num is equal to NaN then the return value will be NaN.
- If num is equal to PositiveInfinity then the return value will be Infinity.
- If num is equal to NegativeInfinity then the return value will be 0.
Example 1:
using System;
class Geeks {
public static void Main()
{
Console.WriteLine(Math.Exp(10.0));
Console.WriteLine(Math.Exp(15.57));
Console.WriteLine(Math.Exp(529.548));
Console.WriteLine(Math.Exp(0.00));
}
}
|
Output:
22026.4657948067
5780495.71030692
9.54496417945595E+229
1
Example 2:
using System;
class Geeks {
public static void Main()
{
Console.WriteLine(Math.Exp(Double.NaN));
Console.WriteLine(Math.Exp(Double.PositiveInfinity));
Console.WriteLine(Math.Exp(Double.NegativeInfinity));
}
}
|
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.math.exp?view=netcore-2.1
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...