C# .Exp()
The Math.Exp() method returns the value of raising e to the power of a given number.
e stands for Euler’s number, an irrational number, with an approximate constant value of 2.71828. It provides a constant base to the natural logarithm or log and can be understood as a limit of a given progression.

Consequently, the Math.Exp() method is the inverse of the Math.Log() method.
Syntax
Math.Exp(double n);
The method takes only one parameter; the variable n (number) of type double. The function will return a positive value of type double unless the value passed is one of the following:
- If
nis0, the function will return1. - If
nisPositiveInfinity, the function will returnPositiveInfinity. - If
nisNegativeInfinity, the function will return0. - If
nisNaN, the function will returnNaN.
Example
The following example applies the Math.Exp() method for six different values. The return values are printed with the Console.WriteLine() method.
using System;namespace MathExpMethod{public class Example{public static void Main(string[] args){double firstCase = Math.Exp(1);double secondCase = Math.Exp(-1);double thirdCase = Math.Exp(0);double fourthCase = Math.Exp(double.PositiveInfinity);double fifthCase = Math.Exp(double.NegativeInfinity);double sixthCase = Math.Exp(double.NaN);Console.WriteLine(firstCase);Console.WriteLine(secondCase);Console.WriteLine(thirdCase);Console.WriteLine(fourthCase);Console.WriteLine(fifthCase);Console.WriteLine(sixthCase);}}}
This example results in the following output:
2.718281828459050.3678794411714421Infinity0NaN
Codebyte Example
The following example is runnable and uses the Math.Exp() method to return the value of raising e to the power of the given double type number:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
- Beginner Friendly.15 hours