.cbrt()
Published Nov 7, 2022Updated Nov 9, 2022
Contribute to Docs
The Math.cbrt()
method returns the cube root of a double
value.
Syntax
Math.cbrt(double num)
The .cbrt()
method will return the cube root of num
. The value of num
can be any real number. Edge cases for this method include:
- If the argument is
NaN
, the return value will beNaN
. - If the argument is ±infinity, the return value will be ±infinity.
Example
Here is an example using the Math.cbrt()
method:
public class Main {public static void main(String[] args) {double a = 27.0;System.out.println("Math.cbrt(" + a + ") returns: " + Math.cbrt(a));double b = -8.0;System.out.println("Math.cbrt(" + b + ") returns: " + Math.cbrt(b));}}
This will result in the following output:
Math.cbrt(27.0) returns: 3.0Math.cbrt(-8.0) returns: -2.0
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.