Java Math log10() Method

The log10() method of Math class returns the base 10 logarithmic value for the specified double argument.

Syntax:

public static double log10(double a)

Parameters:

The parameter ‘a’ represents a double value.

Return Value:

The log10() method returns the base 10 logarithm of a.

Special cases of the log10() method are as follows:

  • It returns NaN, if the argument is NaN or less than zero.
  • It returns positive infinity, if the argument passed is positive infinite.
  • It returns negative infinity, if the argument passed is positive zero or negative zero.
  • It returns n, if the argument is equal to 10n for integer n.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Example 5:

Output: