Java pow() 方法

返回到:Java Number类

pow() 方法用于返回第一个参数的第二个参数次方。

语法

double pow(double base, double exponent)

参数

  • base — 任何原生数据类型。
  • exponent — 任何原生数据类型。

返回值

返回第一个参数的第二个参数次方。

实例

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("pow(%.3f, %.3f) 为 %.3f%n", x, y, Math.pow(x, y));
	}
}

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

e 的值为 2.7183
pow(11.635, 2.760) 为 874.008

返回到:Java Number类

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

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

相关推荐

发表回复

登录后才能评论