What is Math log10(double a) in Java?
log10(double a) is a public static method in java.lang.Math that is used to compute the base 10 logarithm of the argument value. The method accepts a double type value as a parameter and returns a double-precision number, i.e., 64-bit.
By default, the
java.langpackage is loaded, so there is no need to import this package into your program.
Syntax
static double log10(double a)
Parameters
- Double precision number: A 64-bit long
doubletype variable.
Return value
- Logarithm: A
doubletype common logarithm of argument value.
Note: In mathematics, logarithm with base 10 is called common logarithm, i.e., , .
Special cases
double value: If the argument is a double type valuex,log10will return log_{10}(x).NaN: If the argument isNaN(no-argument),log10will returnNaN.less than zero: If the argument is a negative value or less than zero,log10will returnNaN.positive infinity: If the argument value is positive infinity,log10will return positive infinity.positive zero or negative zero: If the argument value is positive zero or negative zero,log10will return negative infinity.exponential number: If the argument value is an exponential number like 10^{n} for integer n, then the result will be n.
Example
This code illustrates multiple cases of the log10() method with different argument values, as discussed above.
class EdPresso {public static void main( String args[] ) {// double type number as argumentSystem.out.println("double type argument: " + Math.log10(2.0));// negative number as argumentSystem.out.println("Negative argument: " + Math.log10(-10));// positive infinity as argumentSystem.out.println("Positive infinity :" + Math.log10(Double.POSITIVE_INFINITY));// Zero as argumentSystem.out.println("Negative or Positive Zero: " + Math.log10(0));// exponential number as argumentSystem.out.println("Exponential number: " + Math.log10(10E+0));}}