Java Math expm1()方法返回歐拉數(shù)e的指定值減去1的冪。
也就是說,也在數(shù)學(xué)中。Math.expm1(4.0) = e4.0-1Math.expm1(x) = ex-1
expm1()方法的語法為:
Math.expm1(double a)
注意:該expm1()方法是靜態(tài)方法。因此,我們可以使用類名Math直接調(diào)用該方法。
a - 要作為e的冪的數(shù)字
返回參數(shù)a的e a-1
注意:此處,e是歐拉數(shù),其值為2.71828
class Main { public static void main(String[] args) { // Math.expm1() 方法 double a = 4.0d; System.out.println(Math.expm1(a)); // 53.598150033144236 //不使用Math.expm1()。 //歐拉數(shù)的值 double euler = 2.71828d; System.out.println(Math.pow(euler, a)-1); // 53.5980031309658 } }
在上面的示例中,我們使用了Math.pow()方法來計算e 4.0值。在這里,我們可以看到
Math.expm1(4.0) = e4.0-1