Skip to content
Related Articles

Related Articles

Improve Article

Java Math exp() method with Example

  • Last Updated : 06 Apr, 2018
Geek Week

The java.lang.Math.exp() returns euler’s number e raised to the power of a double value.

  • If the argument is NaN, the result is NaN.
  • If the argument is positive infinity, then the result is positive infinity.
  • If the argument is negative infinity, then the result is positive zero.

Syntax :

public static double exp(double a)
Parameter : 
a : the exponent part which raises to e. 

Returns :
the value ea, where e is the base of the natural logarithms.

Example : To show working of java.lang.Math.exp() function

// Java program to demonstrate working
// of java.lang.Math.exp() method
import java.lang.Math;
class Gfg {
    // driver code
    public static void main(String args[])
        double x = 3;
        // when both are not infinity
        double result = Math.exp(x);
        double positiveInfinity = 
        double negativeInfinity = 
        double nan = Double.NaN;
        // when 1 is NAN
        result = Math.exp(nan);
        // when one argument is +INF
        result = Math.exp(positiveInfinity);
        result = Math.exp(negativeInfinity);

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :