Home >>Java Math Methods >Java Math.exp() method

Java Math.exp() method

Java Math.exp() method

The Math.exp() in Java Math is used to return the number e of the Euler raised to a double-value power. Here, e is the number of an Euler and is roughly equal to 2.718281828459045.

Syntax

public static double exp(double x)

Parameters

x = This parameter is used to the exponent which raise to e

Returns

It is used to returns the value ex, where e is the base of the natural logarithms.

  1. This method returns the output if the statement is positive or negative double value.
  2. If the argument is Negative, the formula returns 1.0.
  3. If the statement is Positive Infinity, Positive Infinity returns the method.
  4. If Negative Infinity is the statement, Positive Zero will return this method.
  5. This method returns -1 if the statement is -1.

Java Math.exp() Method Example 1


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        double x = 4.0;  
        System.out.println(Math.exp(x));  
    }  
}  

Output:

Java Math.exp() Method Example 2


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        double x = -5.0;  
        System.out.println(Math.exp(x));  
    }  
}  

Output:
0.006737946999085467

No Sidebar ads