目录

static double cbrt(double a)

描述 (Description)

java.lang.Math.cbrt(double a)返回double值的立方根。 对于正有限x,cbrt(-x)== -cbrt(x); 也就是说,负值的立方根是该值的大小的立方根的负数。 特殊情况 -

  • 如果参数是NaN,则结果为NaN。

  • 如果参数是无穷大,则结果是无穷大,其符号与参数相同。

  • 如果参数为零,则结果为零,其参数符号相同。

计算结果必须在精确结果的1 ulp范围内。

声明 (Declaration)

以下是java.lang.Math.cbrt()方法的声明

public static double cbrt(double a)

参数 (Parameters)

a - 一个值。

返回值 (Return Value)

此方法返回a的立方根。

异常 (Exception)

NA

例子 (Example)

以下示例显示了lang.Math.cbrt()方法的用法。

package com.iowiki;
import java.lang.*;
public class MathDemo {
   public static void main(String[] args) {
      // get two double numbers
      double x = 125;
      double y = 10;
      // print the cube roots of three numbers
      System.out.println("Math.cbrt(" + x + ")=" + Math.cbrt(x));
      System.out.println("Math.cbrt(" + y + ")=" + Math.cbrt(y));
      System.out.println("Math.cbrt(-27)=" + Math.cbrt(-27));
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Math.cbrt(125)=5.0
Math.cbrt(10)=2.154434690031884
Math.cbrt(-27)=-3.0
↑回到顶部↑
WIKI教程 @2018