Java Data Type Tutorial - Java Math.log10(double a)








Syntax

Math.log10(double a) has the following syntax.

public static double log10(double a)

Example

In the following code shows how to use Math.log10(double a) method.

/*  w  w w  .ja va 2  s .c  o  m*/
public class Main {

   public static void main(String[] args) {
      double x = 123456.7;
      double y = -123.45;


      // get the base 10 logarithm for x
      System.out.println("Math.log10(" + x + ")=" + Math.log10(x));

      // get the base 10 logarithm for y
      System.out.println("Math.log10(" + y + ")=" + Math.log10(y));


   }
}

The code above generates the following result.