Open In App

Java log10() with example

Last Updated : 29 Mar, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

The java.lang.Math.log10() is one of the Java Math Library method which is used to return the base 10
logarithmic 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 given
    value
    .
  • 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 Negative
    Infinity
    .
  • 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() method
    import 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
    

Similar Reads

Java Guava | LongMath log10(long x, RoundingMode mode) method with Examples
The method log10(long x, RoundingMode mode) of Guava’s LongMath Class accepts two parameters and calculates the base-10 logarithmic value of the first parameter rounded according to the rounding mode specified by the second parameter. Syntax: public static int log10(long x, RoundingMode mode) Parameters: The method takes 2 parameters: x is the long
3 min read
Java Guava | IntMath log10(int x, RoundingMode mode) method with Examples
The log10(int x, RoundingMode mode) method of Guava’s IntMath Class accepts two parameters and calculates the base-10 logarithmic value of the first parameter rounded according to the rounding mode specified by the second parameter. Syntax: public static int log10(int x, RoundingMode mode) Parameters: The method takes 2 parameters: x is the int val
3 min read
StrictMath log10() Method in Java
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
2 min read
BigIntegerMath log10() function | Guava | Java
The method log10(BigInteger x, RoundingMode mode) of Guava's BigIntegerMath class returns the base-10 logarithm of x, rounded according to the specified rounding mode. Syntax: public static int log10(BigInteger x, RoundingMode mode) Parameters: This method takes the following parameters: x: The BigInteger number whose log is to be found. mode: The
3 min read
Java 8 | DoubleToIntFunction Interface in Java with Example
The DoubleToIntFunction Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in a double-valued argument and gives an int-valued result. The lambda expression assigned to an object of DoubleToIntFunction type is used to define
1 min read
Difference Between java.sql.Time, java.sql.Timestamp and java.sql.Date in Java
Across the software projects, we are using java.sql.Time, java.sql.Timestamp and java.sql.Date in many instances. Whenever the java application interacts with the database, we should use these instead of java.util.Date. The reason is JDBC i.e. java database connectivity uses these to identify SQL Date and Timestamp. Here let us see the differences
7 min read
Deque interface in Java with Example
Deque interface present in java.util package is a subtype of the queue interface. The Deque is related to the double-ended queue that supports the addition or removal of elements from either end of the data structure. It can either be used as a queue(first-in-first-out/FIFO) or as a stack(last-in-first-out/LIFO). Deque is the acronym for double-end
10 min read
Java Math asin() method with Example
The java.lang.Math.asin() returns the arc sine of an angle in between -pi/2 and pi/2. Arc sine is also called as an inverse of a sine. If the argument is NaN or its absolute value is greater than 1, then the result is NaN. If the argument is zero, then the result is a zero with the same sign as the argument. Syntax : public static double asin(doubl
1 min read
Arraylist lastIndexOf() in Java with example
The lastIndexOf() method of ArrayList in Java is used to get the index of the last occurrence of an element in an ArrayList object. Syntax : lastIndexOf(element) Parameter : The element whose last index is to be returned. Returns : It returns the last occurrence of the element passed in the parameter. It returns -1 if the element is not found. Prog
2 min read
ArrayList trimToSize() in Java with example
The trimToSize() method of ArrayList in Java trims the capacity of an ArrayList instance to be the list's current size. This method is used to trim an ArrayList instance to the number of elements it contains. Syntax: trimToSize() Parameter: It does not accepts any parameter. Return Value: It does not returns any value. It trims the capacity of this
1 min read
Article Tags :
Practice Tags :