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.
// Java program to demonstrate working // of java.lang.Math.cbrt() method import java.lang.Math; class Gfg { // driver code 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)); // Input Positive Infinity // Output Positive Infinity System.out.println(Math.cbrt(b)); // Input Negative Infinity // Output Negative Infinity System.out.println(Math.cbrt(c)); // Input Positive Zero // Output Positive Zero System.out.println(Math.cbrt(d)); // Input Negative Zero // Output Negative Zero System.out.println(Math.cbrt(e)); } } |
chevron_right
filter_none
Output:
5.0 Infinity -Infinity 0.0 -0.0
Recommended Posts:
- StrictMath cbrt() Method in Java
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java 8 | ArrayDeque removeIf() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java Clock tickMinutes() method in Java with Examples
- Map put() Method in Java with Examples
- Set contains() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



