Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c#

What is Math.Exp() in C#?

Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

C# has a built-in Math class that provides useful mathematical functions and operations. The Math class has the Exp() function, which is used to compute the e raised to a specified number.

Syntax

public static double Exp (double value);

Parameters

  • value: value is of the Double type and represents the input value for which we have to find Exp(). Its range is all double numbers.

Return value

  • Double: Exp() returns a Double number representing the e raised to the power value.
  • 0: Exp() returns 0 if input in value = NegativeInfinity.

e is a mathematical constant with a value of approximately 2.71828.

Exp() is the inverse of Log().

Example

using System;
class Educative
{
static void Main()
{
double result = Math.Exp(-0.16);
System.Console.WriteLine("Exp(-0.16) = "+ result);
double result1 = Math.Exp(0);
System.Console.WriteLine("Exp(0) = "+ result1);
double result2 = Math.Exp(27);
System.Console.WriteLine("Exp(27) = "+ result2);
double result3 = Math.Exp(Double.NegativeInfinity);
System.Console.WriteLine("Exp(-∞) = "+ result3);
}
}

RELATED TAGS

c#

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring