In C#, Exp(Single) is a MathF 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.
Syntax: public static float Exp (float x);
Here, x is the required number of type System.Single which specifies a power.
Return Type: It returns a number e raised to the power x of type System.Single.
Note:
- If x is equal to NaN then the return value will be NaN.
- If x is equal to PositiveInfinity then the return value will be Infinity.
- If x is equal to NegativeInfinity then the return value will be 0.
Example 1:
using System;
class Geeks {
public static void Main()
{
Console.WriteLine(MathF.Exp(7.0f));
Console.WriteLine(MathF.Exp(458.95f));
Console.WriteLine(MathF.Exp(9.487f));
Console.WriteLine(MathF.Exp(0.00f));
}
}
|
Output:
1096.633
Infinity
13187.18
1
Example 2:
using System;
class Geeks {
public static void Main()
{
Console.WriteLine(MathF.Exp(Single.NaN));
Console.WriteLine(MathF.Exp(Single.PositiveInfinity));
Console.WriteLine(MathF.Exp(Single.NegativeInfinity));
}
}
|