java.lang.Math exp(double a)

Description :

This java tutorial shows an example on how to use the exp(double) method of Math class under java.lang package. This method returns the euler’s number raised to the power of double value specified as method argument.

Method Syntax :

public static double exp(double a)

Parameter Input :

DataType Parameter Description
double a the exponent to raise to

Method Returns :

The exp(double a) method simply returns the value ea, where e is the base of the natural logarithms in consideration the following cases:

  • 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.

Compatibility Version :

Requires Java 1.0.2 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of exp(double a) method of Math class. Basically we just raised the e value into an exponent and print the output.

package com.javatutorialhq.java.examples;

import static java.lang.System.*;

import java.util.Scanner;

/*
 * This example source code demonstrates the use of 
 * exp(double a) method of Math class
 */

public class MathEXP {

	public static void main(String[] args) {
		// declare the exponent to be used
		double exponent = 3;
		// raise e to exponent declared
		double expValue = Math.exp(exponent);
		out.println("Value = "+expValue);
	}

}

Sample Output :

Running the exp(double a) method example source code of Math class will give you the following output

Value = 20.085536923187668

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :