static double pow(double a, double b)
描述 (Description)
java.lang.StrictMath.pow()方法返回第一个参数的值,该值是第二个参数的幂。它包括这些情况 -
- 如果第二个参数为正或负零,则返回1.0。
- 如果第二个参数是1.0,则返回与第一个参数相同的参数。
- 如果第二个参数是NaN,则返回NaN。
- 如果第一个参数是NaN而第二个参数是非零,则返回NaN。
声明 (Declaration)
以下是java.lang.StrictMath.pow()方法的声明
public static double pow(double a, double b)
参数 (Parameters)
a - 这是基础
b - 这是指数值。
返回值 (Return Value)
此方法返回值a b 。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StrictMath.pow()方法的用法。
package com.iowiki;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
double d1 = 4.5 , d2 = 6.9, d3 = 1;
// returns d1 to the power d2
double powValue = StrictMath.pow(d1 , d2);
System.out.println(""+ d1 + " to the power of " + d2 + " = " + powValue);
// returns d1 to the power d3
powValue = StrictMath.pow(d1 , d3);
System.out.println(""+ d1 + " to the power of " + d3 + " = " + powValue);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
4.5 to the power of 6.9 = 32148.916823357664
4.5 to the power of 1.0 = 4.5