Facebook Page Twitter Page LinkedIn Page
× Java Tutorial Java Advanced Java Resources


The Java Math log10() method is used to return the base-10 logarithm of a given number. In special cases it returns the following:

  • 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.
  • If the argument is equal to 10n for integer n, then the result is n.

Syntax

public static double log10(double arg)

Parameters

arg Specify the number.

Return Value

Returns the base-10 logarithm of a given number.

Exception

NA.

Example:

In the below example, log10() method is used to calculate the base-10 logarithm of a given number.

public class MyClass {
 public static void main(String[] args) {
  System.out.println(Math.log10(10)); 
  System.out.println(Math.log10(50)); 
  System.out.println(Math.log10(100));     
 }
}

The output of the above code will be:

1.0
1.6989700043360187
2.0

❮ Java Math Methods