Home » 
        Java programming language
    
    Java StrictMath log10() method with example
    
    
    
            
        StrictMath Class log10() method: Here, we are going to learn about the log10() method of StrictMath Class with its syntax and example.
        Submitted by Preeti Jain, on December 26, 2019
    
    StrictMath Class log10() method
    
        - log10() method is available in java.lang package.
- log10() method is used to return the logarithm of the given (base 10) of the given argument in the method.
- log10() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
- log10() method does not throw any exception.
Syntax:
    public static double log10(double d);
    Parameter(s):
    
        - double d – represents the double type argument.
Return value:
    The return type of this method is double – it returns the logarithm (base 10) of the given argument.
    Note:
    
        - If we pass NaN, method returns NaN.
- If we pass a value which is equal to 10*N (Here, N is an integer value), method returns the N.
- If we pass a positive infinity, method returns the same (i.e. positive infinity).
- If we pass 0 (negative or positive), method returns the negative infinity.
Example:
// Java program to demonstrate the example of 
// log10(double d) method of StrictMath Class.
public class Log10 {
    public static void main(String[] args) {
        // variable declarations
        double d1 = 7.0 / 0.0;
        double d2 = -0.0;
        double d3 = 6054.2;
        // Display previous value of d1,d2,d3
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);
        // Here , we will get (Infinity) because we are
        // passing parameter whose value is (-infinity)
        System.out.println("StrictMath.log10(d1): " + StrictMath.log10(d1));
        // Here , we will get (-Infinity) because we are
        // passing parameter whose value is (-0.0)
        System.out.println("StrictMath.log10(d2): " + StrictMath.log10(d2));
        // Here , we will get (log [10 raised to the power of the given argument])
        // and we are passing parameter whose value is (6054.2)
        System.out.println("StrictMath.log10(d3): " + StrictMath.log10(d3));
    }
}
Output
d1: Infinity
d2: -0.0
d3: 6054.2
StrictMath.log10(d1): Infinity
StrictMath.log10(d2): -Infinity
StrictMath.log10(d3): 3.782056763740091
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement