即
Math.expm1(4.0) = e4.0-1
。同样在Math中,
Math.expm1(x) = e
x
-1
.
expm1()
方法的语法是:
Math.expm1(double a)
注意: expm1() 方法是一个静态方法。因此,我们可以使用类名 Math 直接调用该方法。
expm1() 参数
a-被提升为 e 的幂的数字expm1() 返回值
返回 ea-1 作为参数 a
注意: 这里,e 是欧拉数,其值为 2.71828
示例: Java Math.expm1()
class Main { public static void main(String[] args) { // Math.expm1() method double a = 4.0d; System.out.println(Math.expm1(a)); // 53.598150033144236 // without using Math.expm1() // value of Euler Number 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