Java Math expm1() method with Example
The java.lang.Math.expm1() returns ex -1. Note that for values of x near 0, the exact sum of expm1(x) + 1 is much closer to the true result of ex than exp(x).
- 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 -1.0.
- If the argument is zero, then the result is a zero with the same sign as the argument.
public static double expm1(double x) Parameter: x-the exponent part which raises to e.
The method returns the value ex-1, where e is the base of the natural logarithms.
Example : To show working of java.lang.Math.expm1() function
19.085536923187668 NaN Infinity -1.0 0.0
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.