Facebook Page Twitter Page LinkedIn Page
× C# Tutorial C# Advanced C# Resources


The C# Math Exp() method returns e raised to the power of specified number, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282. In special cases it returns the following:

  • If the argument is NaN, the method returns NaN.
  • If the argument is PositiveInfinity, the method returns PositiveInfinity.
  • If the argument is NegativeInfinity, the method returns zero.

Syntax

public static double Exp (double x);  

Parameters

x Specify the Exponent of e.

Return Value

Returns e raised to the power of specified number.

Example:

In the below example, Exp() method is used to calculate e raised to the power of specified number.

using System;

class MyProgram {
  static void Main(string[] args) {
    Console.WriteLine(Math.Exp(2)); 
    Console.WriteLine(Math.Exp(-2)); 
    Console.WriteLine(Math.Exp(1.5)); 
    Console.WriteLine(Math.Exp(-1.5));  
  }
}

The output of the above code will be:

7.38905609893065
0.1353352832366127
4.4816890703380645
0.22313016014842982

❮ C# Math Methods

5