Close

Java - Math.log10() Examples

Java Java API 


Class:

java.lang.Math

java.lang.Objectjava.lang.Objectjava.lang.Mathjava.lang.MathLogicBig

Method:

public static double log10(double a)

Returns the base 10 logarithm of a double value.


Examples


package com.logicbig.example.math;

public class Log10Example {

public static void main(String... args) {
findLog10(5);
findLog10(24.13);
findLog10(1);
findLog10(-541.23);
findLog10(0);
findLog10(Double.POSITIVE_INFINITY);
findLog10(Double.NEGATIVE_INFINITY);
}

private static void findLog10(double x) {
double result = Math.log10(x);
System.out.printf("Math.log10(%s) = %s%n", x, result);
}
}

Output

Math.log10(5.0) = 0.6989700043360189
Math.log10(24.13) = 1.3825573219087859
Math.log10(1.0) = 0.0
Math.log10(-541.23) = NaN
Math.log10(0.0) = -Infinity
Math.log10(Infinity) = Infinity
Math.log10(-Infinity) = NaN




See Also