StrictMath log() Method In Java
The Java.lang.StrictMath.log() is an inbuilt method of StrictMath class which is used to calculate the natural logarithm i.e., log with base e, of a given double value. It gives rise to three special results:
- It returns a positive infinity when the argument is positive infinity.
- It returns NaN when the argument is NaN or less than zero.
- The result is negative infinity when the argument is positive zero or negative zero.
public static double log(double num)
Parameters: The method accepts one parameter num of double type whose logarithmic value is to be found.
Return Value: The method returns the value of natural logarithm of num.
Input: num = 5.0 Output: 1.6094379124341003 Input: num = 10.0 Output: 2.302585092994046
Below programs illustrate the Java.lang.StrictMath.log() Method:
Log value of 10.0 = 2.302585092994046 Log value of 25.2 = 3.2268439945173775
Log value of 0.0 = -Infinity Log value of Infinity = Infinity Log value of 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.