Java sqrt() 方法

返回到:Java Number类

sqrt() 方法用于返回参数的算术平方根。

语法

double sqrt(double d)

参数

  • — 任何原生数据类型。

返回值

返回参数的算术平方根。

实例

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));
	}
}

编译以上程序,输出结果为:

e 的值为 2.7183
sqrt(11.635) 为 3.411

返回到:Java Number类

作者:terry,如若转载,请注明出处:https://www.web176.com/java_api/19744.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2023年5月6日
下一篇 2023年5月6日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注