cbrt(): This method is available in the Math Class of Java.
Syntax:
double java.lang.Math.cbrt(double a)
This method takes one argument of type double. This method returns the cube root of a double value. For positive finite x, cbrt(-x) ==-cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.
Special cases:
1. If the argument is NaN, then the result is NaN.
2. If the argument is infinite, then the result is an infinity with the same sign as the argument.
3. If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result.
Parameters: One parameter is required for this method.
a: A value.
This method returns the cube root of a.
Approach
Java
public class Cbrt {public static void main(String[] args) {double x = 27;System.out.println(Math.cbrt(x));}}
Output:
3.0
No comments:
Post a Comment