MathF.Exp() Method in C# with Examples
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:
// C# Program to illustrate the // MathF.Exp(Single) Method using System; class Geeks { // Main Method public static void Main() { // using the method Console.WriteLine(MathF.Exp(7.0f)); Console.WriteLine(MathF.Exp(458.95f)); Console.WriteLine(MathF.Exp(9.487f)); Console.WriteLine(MathF.Exp(0.00f)); } } |
1096.633 Infinity 13187.18 1
Example 2:
// C# Program to illustrate the // MathF.Exp(Single) Method by // taking NaN, PositiveInfinity // and NegativeInfinity] using System; class Geeks { // Main Method public static void Main() { // Taking NaN Console.WriteLine(MathF.Exp(Single.NaN)); // Taking PositiveInfinity Console.WriteLine(MathF.Exp(Single.PositiveInfinity)); // Taking NegativeInfinity Console.WriteLine(MathF.Exp(Single.NegativeInfinity)); } } |
NaN Infinity 0
Recommended Posts:
- MathF.Sin() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- UInt16.GetHashCode Method in C# with Examples
- Stack.ToString() Method in C# with examples
- BitArray.RightShift() Method in C# with Examples
- BitArray.LeftShift() Method in C# with Examples
- C# | Stack<T>.TrimExcess Method with Examples
- C# | Queue<T>.TrimExcess Method with Examples
- Decimal.GetHashCode Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



