All methods of java.lang.StrictMath class : Set 1, Set 2
The java.lang.StrictMath.exp() is an inbuilt method in Java is used to return a Euler number raised to the power of the specified double value. It gives rise to three special results:
- The result is positive infinity when the given argument is positive infinity.
- The result is positive zero when the argument is negative infinity.
- The result is NaN when the given argument is NaN.
Syntax :
public static double exp(double num)
Parameters: This method accepts one parameter num which is of double type which is the exponent to raise e to.
Return Value: The method returns the value e^num, where e is the base of the natural logarithms.
Examples:
Input: num = 7 Output: 1096.6331584284585 Input: num = (1.0 / 0.0) Output: Infinity
Below programs illustrate the java.lang.StrictMath.exp() method:
Program 1:
// Java praogram to illustrate the // java.lang.StrictMath.exp() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 0.0, num2 = (1.0 / 0.0); double num3 = 4; // Returns Euler's number e raised to the given power double expValue = StrictMath.exp(num1); System.out.println("The exp value of "+ num1+" = " + expValue); expValue = StrictMath.exp(num2); System.out.println("The exp value of "+ num2+" = " + expValue); expValue = StrictMath.exp(num3); System.out.println("The exp value of "+ num3+" = " + expValue); } } |
The exp value of 0.0 = 1.0 The exp value of Infinity = Infinity The exp value of 4.0 = 54.598150033144236
Program 2:
// Java praogram to illustrate the // java.lang.StrictMath.exp() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = -0.0, num2 = (1.0 / 0.0); double num3 = 14; // Returns Euler's number e raised to the given power double expValue = StrictMath.exp(num1); System.out.println("The exp value of "+ num1+" = " + expValue); expValue = StrictMath.exp(num2); System.out.println("The exp value of "+ num2+" = " + expValue); expValue = StrictMath.exp(num3); System.out.println("The exp value of "+ num3+" = " + expValue); } } |
The exp value of -0.0 = 1.0 The exp value of Infinity = Infinity The exp value of 14.0 = 1202604.2841647768
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- StrictMath log() Method In Java
- StrictMath tan() Method in Java
- StrictMath pow() Method in Java
- StrictMath sin() Method in Java
- StrictMath sinh() Method in Java
- StrictMath cos() Method in Java with Examples
- StrictMath cbrt() Method in Java
- StrictMath hypot() Method in Java
- StrictMath log10() Method in Java
- StrictMath log1p() Method in Java
- StrictMath toRadians() Method in Java
- StrictMath acos() Method in Java
- StrictMath multiplyExact() Method in Java
- StrictMath toDegrees() Method in Java
- StrictMath atan() Method in Java
- StrictMath nextDown() Method in Java
- StrictMath scalb() Method in Java
- StrictMath fma() method in Java with Examples
- StrictMath nextAfter() Method in Java
- StrictMath getExponent() Method In Java
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.

