Java log10() with example - GeeksforGeeks

29 Mar, 2018
The java.lang.Math.log10() is one of the Java Math Library method which is used to return the base 10logarithmic value of given double value as a parameter. There are various cases :
If the argument is positive double value, Math.log10() method will return the logarithm of a givenvalue.
If the argument is NaN or less than zero, Math.log10() method will return NaN.
If the argument is positive infinity, Math.log10() method will return the result as Positive Infinity.
If the argument is positive or negative zero, Math.log10() method will return the result as NegativeInfinity.Syntax :public static double log10(double a)Parameter :a : User inputReturn :This method returns the base 10 logarithm of a.Example :To show working of java.lang.Math.log10() method.// Java program to demonstrate working// of java.lang.Math.log10() methodimport java.lang.Math;  class Gfg {      // driver code    public static void main(String args[])    {          double a = 1000;        double b = 145.256;        double c = -6.04;        double d = 1.0 / 0;        double e = 0;          // A power of 10 as input        System.out.println(Math.log10(a));          // positive double value as argument,        // output double value        System.out.println(Math.log10(b));          // negative integer as argument,        // output NAN        System.out.println(Math.log10(c));          // positive infinity as argument,        // output Infinity        System.out.println(Math.log10(d));          // positive zero as argument,        // output -Infinity        System.out.println(Math.log10(e));    }}Output:3.0
2.1621340805671756
NaN
Infinity
-Infinity
My Personal Notes
arrow_drop_upSave
Syntax :
public static double log10(double a)
Parameter :
a : User input
Return :
This method returns the base 10 logarithm of a.
Example :To show working of java.lang.Math.log10() method.
// Java program to demonstrate working// of java.lang.Math.log10() methodimport java.lang.Math;  class Gfg {      // driver code    public static void main(String args[])    {          double a = 1000;        double b = 145.256;        double c = -6.04;        double d = 1.0 / 0;        double e = 0;          // A power of 10 as input        System.out.println(Math.log10(a));          // positive double value as argument,        // output double value        System.out.println(Math.log10(b));          // negative integer as argument,        // output NAN        System.out.println(Math.log10(c));          // positive infinity as argument,        // output Infinity        System.out.println(Math.log10(d));          // positive zero as argument,        // output -Infinity        System.out.println(Math.log10(e));    }}
3.0
2.1621340805671756
NaN
Infinity
-Infinity

java-math
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
LinkedList in Java