java math log10 method

java math log10 method

In java Math class, log10 method is used to get the base 10 logarithm of a double value.

  • If the number is equal to 10n for integer n, then the result is n. In particular, if the number is 1.0 (100), then the result is positive zero.
  • If the number is NaN or less than zero, then the result is NaN.
  • If the number is positive infinity, then the result is positive infinity.
  • If the number is positive zero or negative zero, then the result is negative infinity.
/**
 * @author lautturi.com 
 * Java example: get the 10-based logarithm of a number
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {
		System.out.println(Math.log10(-3));
		System.out.println(Math.log10(2));
		System.out.println(Math.log10(0));
		System.out.println(Math.log10(3.14));
		System.out.println(Math.log10(1));
	}
}
‮‬Source:www.lautturi.com

output:

NaN
0.3010299956639812
-Infinity
0.49692964807321494
0.0
Created Time:2017-10-04 15:25:18  Author:lautturi