java.lang.Math.exp()返回欧拉数e,该数字e增大为双精度值的幂。
如果参数为NaN,则结果为NaN。
如果参数为正无穷大,则结果为正无穷大。
如果参数为负无穷大,则结果为正零。
用法:
public static double exp(double a)
Parameter:
a:the exponent part which raises to e.
返回值:
值ea,其中e是自然对数的底数。
例:演示java.lang.Math.exp()函数的工作
// Java program to demonstrate working
// of java.lang.Math.exp() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
double x = 3;
// when both are not infinity
double result = Math.exp(x);
System.out.println(result);
double positiveInfinity =
Double.POSITIVE_INFINITY;
double negativeInfinity =
Double.NEGATIVE_INFINITY;
double nan = Double.NaN;
// when 1 is NAN
result = Math.exp(nan);
System.out.println(result);
// when one argument is +INF
result = Math.exp(positiveInfinity);
System.out.println(result);
result = Math.exp(negativeInfinity);
System.out.println(result);
}
}
输出:
20.085536923187668
NaN
Infinity
0.0