static double cbrt(double a)
描述 (Description)
java.lang.StrictMath.cbrt()方法返回double值的立方根。 对于正有限x, cbrt(-x) == -cbrt(x); 也就是说,负值的立方根是该值的大小的立方根的负数。这包括这些情况 -
- 如果参数是NaN,则结果为NaN。
- 如果参数是无穷大,则结果是无穷大,其符号与参数相同。
- 如果参数为零,则结果为零,其参数符号相同。
声明 (Declaration)
以下是java.lang.StrictMath.cbrt()方法的声明
public static double cbrt(double a)
参数 (Parameters)
a - 这是双值
返回值 (Return Value)
此方法返回a的立方根。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StrictMath.cbrt()方法的用法。
package com.iowiki;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
double d1 = 8.05 , d2 = 729, d3 = 0;
// returns the cube root of a double value
double cbrtValue = StrictMath.cbrt(d1);
System.out.println("Cube root of " + d1 + " = " + cbrtValue);
cbrtValue = StrictMath.cbrt(d2);
System.out.println("Cube root of " + d2 + " = " + cbrtValue);
cbrtValue = StrictMath.cbrt(d3);
System.out.println("Cube root of " + d3 + " = " + cbrtValue);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Cube root of 8.05 = 2.0041580161269152
Cube root of 729 = 9.0
Cube root of 0 = 0.0