Java Math log10() Method

java math log10() method

Java Math Class

Java Math class provides several methods to perform several operations on math calculations like max(), min(), sin(), cos(), round(), ceil(), floor(), abs() etc.
The java.lang.Math class contains various methods for performing basic numeric operations

Here, in the page we will discuss about the math log10() Method in java.

Java Math log10() Method :

This function returns the base 10 logarithm of a double value.

Special Points :

  • The result is NaN if the argument is NaN or less than zero.
  • If the argument is true, then the conclusion must also be true.
  • If the argument is either positive zero or negative zero, the result is negative infinity.
  • For an integer n, the result is n if the argument is equal to 10n.

Syntax  :

public static double log10(double a)

Example 1 :  

Run

public class Main {
    public static void main(String[] args) {
        
        //declare variables
        double x = 100.0;
        double y = 1000.0;
        
        //printing output for log10 method.
        System.out.println("log10(" + x + ") = " + Math.log10(x));
        System.out.println("log10(" + y + ") = " + Math.log10(y));
    }
}

Output :

log10(100.0) = 2.0
log10(1000.0) = 3.0

Example 2  :  

Run

public class Main {
  
    public static void main(String[] args) {
         
         //declaring variables
         double x = 100;
         double y = 505.5;
         double z = 90.7;
         double e = 0.0;
         
         //printing output for log10 method.
         System.out.println("Math.log10(" + x + ") = " + Math.log10(x));
         System.out.println("Math.log10(" + y + ") = " + Math.log10(y));
         System.out.println("Math.log10(" + z + ") = " + Math.log10(z));
         System.out.println("Math.log10(" + e + ") = " + Math.log10(e));
    }
   
}

Output :

Math.log10(100.0) = 2.0
Math.log10(505.5) = 2.70372115992702
Math.log10(90.7) = 1.9576072870600953
Math.log10(0.0) = -Infinity

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription