# Get exponential value of a number using Math.exp in Java

Java 8Object Oriented ProgrammingProgramming

To get the exponential value of a number in Java, we use the java.lang.Math.exp() method. The Math.exp() returns a double value which is the Euler’s number e raised to the power of the argument. If the parameter is NaN, the result obtained is NaN. If the argument is positive infinity, then the result is positive infinity. In case the argument is negative infinity, then the output is positive zero.

Declaration − The java.lang.Math.exp() method is declared as follows:

public static double exp(double a)

where a is the number representing the power to which e is raised to.

Let us see a program to get an exponential value of a number using Math.exp in Java.

## Example

Live Demo

import java.lang.Math;
public class Example {
public static void main(String[] args) {
// declaring and initializing some double values
double a = -0.7;
double b = 1;
double c = 5;
//printing their exponential values
System.out.println("Exponential value of " + a + " = " + Math.exp(a));
System.out.println("Exponential value of " + b + " = " + Math.exp(b));
System.out.println("Exponential value of " + c + " = " + Math.exp(c));
}
}

## Output

Exponential value of -0.7 = 0.4965853037914095
Exponential value of 1.0 = 2.718281828459045
Exponential value of 5.0 = 148.4131591025766
Published on 04-Jan-2019 06:45:19