Java.lang.StrictMath.exp() Method


Advertisements


Description

The java.lang.StrictMath.exp() method returns Euler's number e raised to the power of a double value.It include these cases:

  • If the argument is NaN, then 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.

Declaration

Following is the declaration for java.lang.StrictMath.exp() method

public static double exp(double a)

Parameters

  • a -- This is the exponent to raise e to.

Return Value

This method returns the value ea, where e is the base of the natural logarithms.

Exception

  • NA

Example

The following example shows the usage of java.lang.StrictMath.exp() method.

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {
  
   double d1 = 0.0 , d2 = -0.0, d3 = (1.0/0.0), d4 = 5;

   // returns Euler's number e raised to the power positive 0 
   double eulerValue = StrictMath.exp(d1); 
   System.out.println("Euler value of d1 = " + eulerValue);
        
   // returns Euler's number e raised to the power negative 0
   eulerValue = StrictMath.exp(d2); 
   System.out.println("Euler value of d2 = " + eulerValue);
       
   // returns Euler's number e raised to the power infinity
   eulerValue = StrictMath.exp(d3);
   System.out.println("Euler value of d3 = " + eulerValue);
       
   // returns Euler's number e raised to the power 5
   eulerValue = StrictMath.exp(d4);
   System.out.println("Euler value of d4 = " + eulerValue);
  }
}

Let us compile and run the above program, this will produce the following result:

Euler value of d1 = 1.0
Euler value of d2 = 1.0
Euler value of d3 = Infinity
Euler value of d4 = 148.4131591025766

java_lang_strictmath.htm

Advertisements