Java Math log() method with example
The java.lang.Math.log() method returns the natural logarithm (base e) of a double value as a parameter. There are various cases :
- If the argument is NaN or less than zero, then the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is positive zero or negative zero, then the result is negative infinity.
public static double log(double a)
a : User input
This method returns the value ln a.
Example :To show working of java.lang.Math.log() method.
NaN Infinity -Infinity 4.978497702968366
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.