java math log method

https://w‮uttual.ww‬ri.com
java math log method

In java Math class, log method is used to get the natural logarithm (base e) of a double value.

  • 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.
  • If the number is 1.0, then the result is positive zero.
/**
 * @author lautturi.com 
 * Java example:
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {
		//  the natural logarithm (base e) of number
		System.out.println(Math.log(-3));
		System.out.println(Math.log(3));
		System.out.println(Math.log(0));
		System.out.println(Math.log(3.14));
		System.out.println(Math.log(1));

	}
}

output:

NaN
1.0986122886681098
-Infinity
1.144222799920162
0.0
Created Time:2017-10-04 15:22:17  Author:lautturi