Saturday, October 25, 2025
HomeLanguagesJavaStrictMath exp() Method in Java

StrictMath exp() Method in Java

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




// Java program 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);    }
}


Output: 

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




// Java program 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);
    }
}


Output: 

The exp value of -0.0 = 1.0
The exp value of Infinity = Infinity
The exp value of 14.0 = 1202604.2841647768

 

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS