Java 教程
sqrt() 方法用于返回參數(shù)的算術(shù)平方根。
double sqrt(double d)
d -- 任何原生數(shù)據(jù)類型。
返回參數(shù)的算術(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("sqrt(%.3f) 為 %.3f%n", x, Math.sqrt(x)); ????} }
編譯以上程序,輸出結(jié)果為:
e 的值為 2.7183 sqrt(11.635) 為 3.411