log(): This method is available in the Math class of Java.
Syntax:
double java.lang.Math.log(double a)
This method takes one argument of type double as its parameter. This method returns the natural logarithm (base e) of a double value.
Special cases:
1. If the argument is NaN or less than zero, then the result is NaN.
2. If the argument is positive infinity, then the result is positive infinity.
3. If the argument is positive zero or negative zero, then the result is negative infinity.
Parameters: One parameter is required for this method.
a: A value whose natural logarithm value is to be determined.
Returns: the value ln(a), the natural logarithm of a.
For Example:
Math.log(1010) = > It returns 6.917705609835305.
Approach
Java
public class Log {public static void main(String[] args) {double a = 1010;System.out.println(Math.log(a));}}
Output:
6.917705609835305
No comments:
Post a Comment