Java log () method
log () method is used to return the value of the parameters of the natural log base.
grammar
double log(double d)
parameter
d - any native data types.
return value
Returns the values of the parameters of the natural log base.
Examples
public class Test{ public static void main(String args[]){ double x = 11.635; double y = 2.76; System.out.printf("e 的值为 %.4f%n", Math.E); System.out.printf("log(%.3f) 为 %.3f%n", x, Math.log(x)); } }
Compile the above program, the output is:
e 的值为 2.7183 log(11.635) 为 2.454