StrictMath log10() Method in Java
java.lang.StrictMath.log10()
base 10 logarithm
Syntax:
public static double log10(double val)
Parameters:
val
base 10
Return Values:
val
- 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
java.lang.StrictMath.log10()
Program 1:
// 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)); } } |
Output:
Base 10 Logarithm of 2018.00567 is 3.3049223821418496 Base 10 Logarithm of 100000.0 is 5.0
Program 2:
// 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 )); } } |
Output:
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()