EN
Java - Math.log10() method example
0 points
The Math.log10()
method returns the logarithm with base 10 of a number.
xxxxxxxxxx
1
public class MathExample {
2
3
public static void main(String[] args) {
4
// Logarithm with base 10:
5
// x y
6
System.out.println( Math.log10( 1 ) ); // 0.0
7
System.out.println( Math.log10( 3 ) ); // 0.47712125471966244
8
System.out.println( Math.log10( 10 ) ); // 1.0
9
System.out.println( Math.log10( 100 ) ); // 2.0
10
System.out.println( Math.log10( 1000 ) ); // 3.0
11
12
System.out.println( Math.log10( -1 ) ); // NaN
13
System.out.println( Math.log10( 0 ) ); // -Infinity
14
System.out.println( Math.log10( Double.POSITIVE_INFINITY ) ); // +Infinity
15
}
16
}
The Math.log10()
method is presented on the following chart:

Syntax |
xxxxxxxxxx 1 package java.lang; 2 3 public final class Math { 4 5 public static double log10(double x) { ... } 6 7 }
|
Parameters | x - double value in the range 0 to +Infinity (primitive value). |
Result |
If If If |
Description |
|