The java.lang.StrictMath.log10() is an inbuilt method in Java which accepts a double value as parameter and returns the base 10 logarithm of that value. Thus calculating the base 10 logarithmic value for a given parameter.
Syntax:
public static double log10(double val)
Parameters: The function accepts a double value, val as parameter whose base 10 logarithm is calculated.
Return Values: This function returns the base 10 logarithm of val based on the following conditions:
- The function returns NaN if argument passed is NaN or less than zero
- The function returns positive infinity if argument passed is positive infinity
- The function returns negative infinity if the argument passed is zero.
- The function returns a if the argument passed is

Examples:
Input : 2018.0 Output : 7.609862200913554 Input : 1000000.0 Output : 6.0
Below programs illustrate the working of java.lang.StrictMath.log10() :
Program 1: In this program , finite non-zero arguments are passed as parameter.
// Java Program to illustrate // StrictMath.log10() function import java.io.*; import java.lang.*; class GFG { public static void main(String[] args) { double val1 = 2018.00567 , val2 = 100000.0; // Argument passed is infinite System.out.println("Base 10 Logarithm of " + val1 + " is " + StrictMath.log10(val1)); // Passing zero as argument System.out.println("Base 10 Logarithm of "+ val2 +" is "+ StrictMath.log10(val2)); } } |
Base 10 Logarithm of 2018.00567 is 3.3049223821418496 Base 10 Logarithm of 100000.0 is 5.0
Program 2: In this program, infinity and zero are passed as parameter.
// Java Program to illustrate // StrictMath.log10() function import java.io.*; import java.lang.*; class GFG { public static void main(String[] args) { double val = 2018/(0.0); System.out.println("Base 10 Logarithm of " + val + " is " + StrictMath.log10(val)); System.out.println("Base 10 Logarithm of 0 is " + StrictMath.log10(0)); } } |
Base 10 Logarithm of Infinity is Infinity Base 10 Logarithm of 0 is -Infinity
Reference:https://docs.oracle.com/javase/8/docs/api/java/lang/StrictMath.html#log10()
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- Java Guava | LongMath log10(long x, RoundingMode mode) method with Examples
- Java Guava | IntMath log10(int x, RoundingMode mode) method with Examples
- Java log10() with example
- BigIntegerMath log10() function | Guava | Java
- Java.lang.StrictMath class in Java | Set 1
- Java.lang.StrictMath class in Java | Set 2
- StrictMath log1p() Method in Java
- StrictMath IEEEremainder() Method in Java
- StrictMath nextAfter() Method in Java
- StrictMath tan() Method in Java
- StrictMath atan2() Method in Java
- StrictMath hypot() Method in Java
- StrictMath acos() Method in Java
- StrictMath asin() Method in Java With Examples
- StrictMath atan() Method in Java
- StrictMath cbrt() Method in Java
- StrictMath ceil() Method in Java with Examples
- StrictMath cos() Method in Java with Examples
- StrictMath exp() Method in Java
- StrictMath cosh() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

