Java cbrt() method with Examples
The java.lang.Math.cbrt() method returns the cube root of a double value.
Note:
- Cube root of a negative value is the negative of the cube root of that value’s magnitude.
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Syntax :
public static double cbrt(double a)
Parameter :
a : an argument
Return :
This method returns the cube root of a.
Example :To show working of java.lang.Math.cbrt() method.
import java.lang.Math;
class Gfg {
public static void main(String args[])
{
double a = 125.0 ;
double b = 1.0 / 0 ;
double c = -( 1.0 / 0 );
double d = 0.0 ;
double e = - 0.0 ;
System.out.println(Math.cbrt(a));
System.out.println(Math.cbrt(b));
System.out.println(Math.cbrt(c));
System.out.println(Math.cbrt(d));
System.out.println(Math.cbrt(e));
}
}
|
Output:
5.0
Infinity
-Infinity
0.0
-0.0
Last Updated :
08 Apr, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...