Java.lang.StrictMath 类

java.lang.StrictMath.cbrt() 方法返回给定数字的立方根。在特殊情况下,它返回以下内容:

  • 如果参数为 NaN,则结果为 NaN。
  • 如果参数为无穷大,则结果为无穷大与参数相同的符号。
  • 如果参数为零,则结果是与参数相同符号的零。

语法

public static double cbrt(double a)

参数

a 指定一个数字。

返回值

返回指定数字的立方根。

异常

无。

示例:

在下面的示例中,cbrt()方法用于找出给定数字的立方根。

import java.lang.*;

public class MyClass {
 public static void main(String[] args) {
  System.out.println(StrictMath.cbrt(25)); 
  System.out.println(StrictMath.cbrt(30)); 
  System.out.println(StrictMath.cbrt(35.5)); 
  System.out.println(StrictMath.cbrt(-25));     
 }
}

上述代码的输出将是:

2.924017738212866
3.1072325059538586
3.2865692257212147
-2.924017738212866