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); System.out.println(result); double positiveInfinity = Double.POSITIVE_INFINITY; double negativeInfinity = Double.NEGATIVE_INFINITY; double nan = Double.NaN; // when 1 is NAN result = Math.exp(nan); System.out.println(result); // when one argument is +INF result = Math.exp(positiveInfinity); System.out.println(result); result = Math.exp(negativeInfinity); System.out.println(result); } } |
20.085536923187668 NaN Infinity 0.0
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- StrictMath exp() Method in Java
- Java Math asin() method with Example
- Java Math log() method with example
- Java Math hypot() method with Example
- Java Math getExponent() method with Example
- Java Math getExponent() method with Example
- Java Math expm1() method with Example
- Java Math round() method with Example
- Math pow() method in Java with Example
- Java Math nextAfter() method with Example
- Java.math.BigInteger.modInverse() method in Java
- Java.math.BigInteger.probablePrime() method in Java
- Java.lang.Math Class in Java | Set 1
- Java.lang.Math Class in Java | Set 2
- java.lang.Math.atan2() in Java
- Java Math random() method with Examples
- Java Math min() method with Examples
- Java Math max() method with Examples
- Math floorDiv() method in Java
- Java Math abs() method with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

