Java.lang.StrictMath.cbrt() 方法
描述
java.lang.StrictMath.cbrt() 方法返回双精度值的立方根。 对于正有限 x,cbrt(-x) == -cbrt(x); 即负值的立方根是该值大小的立方根的负数。这包括这些情况 −
- 如果参数为 NaN,则结果为 NaN。
- 如果参数是无限的,则结果是与参数相同符号的无穷大。
- 如果参数为零,则结果为零,符号与参数相同。
声明
以下是 java.lang.StrictMath.cbrt() 方法的声明。
public static double cbrt(double a)
参数
a − 这是双精度值
返回值
此方法返回 a 的立方根。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.cbrt() 方法的使用。
package com.tutorialspoint;
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

