Home >>Java Math Methods >Java Math.log10() method

Java Math.log10() method

Java Math.log10() method

The Math.log10() Method in Java Math is used when the base is 10 to find out a number's Logarithmic. This method returns a double value of the base 10 logarithm.

Syntax

public static double log10(double x)

Parameters

x= This parameter is used for a value entered by user

Returns

It is used to returns the base 10 logarithm of a.

  1. This method returns the logarithm of a given value if the argument is Positive value.
  2. If the argument for integer n is equal to 10n, the method must return n.
  3. This method will return -1 if the statement is Negative value.
  4. This method returns -1 if the statement is -1.
  5. If Positive Infinity is the statement, then this method returns Positive Infinity.
  6. This method returns Negative Infinity if the argument is positive or negative Zero.

Java Math.log10() Method Example 1


public class MyClass
{  
    public static void main(String[] args)   
    {  
        double a = 23.4;  
        System.out.println(Math.log10(a));  
    }  
}  

Output:
1.3692158574101427

Java Math.log10() Method Example 2


public class MyClass 
{  
    public static void main(String[] args)   
    {  
        double a = 50000;  
        System.out.println(Math.log10(a));  
    }  
}  

Output:
4.698970004336019

No Sidebar ads