log10(): This method is available in the Math class of Java.
Syntax:
double java.lang.Math.log10(double a)
This method takes one argument of type double as its parameter. This method returns the base 10 logarithms 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.
4. If the argument is equal to 10n for integer n, then the result is n.
Parameters: One parameter is required for this method.
a: a value.
Returns: The base 10 logarithms of a.
For Example:
Math.log10(1000) = > It returns 3.0
Approach
Java
public class Log10 {public static void main(String[] args) {double a = 1000;System.out.println(Math.log10(a));}}
Output:
3.0
No comments:
Post a Comment