Java 教程
log() 方法用于返回參數(shù)的自然數(shù)底數(shù)的對(duì)數(shù)值。
double log(double d)
d -- 任何原生數(shù)據(jù)類型。
返回參數(shù)的自然數(shù)底數(shù)的對(duì)數(shù)值。
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)); ????} }
編譯以上程序,輸出結(jié)果為:
e 的值為 2.7183 log(11.635) 為 2.454