Monday, February 16, 2026
HomeLanguagesJavaStrictMath cbrt() Method in Java

StrictMath cbrt() Method in Java

The java.lang.StrictMath.cbrt() is an inbuilt method in Java which is used to return the cube root of a given double value. The method shows three special results: 

  • The result is a zero with the same sign as the argument when the given argument is zero.
  • The result is infinity with the same sign of argument when the argument is infinite.
  • The result is NaN when the given argument is NaN.

Syntax:  

public static double cbrt(double num)

Parameters: This method accepts one parameter num which is of double type whose cube root is required to be found.
Return Value : The method returns the cube root of num.
Below programs illustrate the java.lang.StrictMath.cbrt() method: 
Program 1:  

java




// Java program to illustrate the
// java.lang.StrictMath.cbrt()
import java.lang.*;
 
public class Geeks {
 
    public static void main(String[] args)
    {
 
        double val1 = 8.05, val2 = 27, val3 = 0;
 
        // It returns the cube root of a double value
        double cbrtvalue = StrictMath.cbrt(val1);
        System.out.println("Cube root of "+val1+
                                  " = " + cbrtvalue);
 
        cbrtvalue = StrictMath.cbrt(val2);
        System.out.println("Cube root of "+val2+
                                  " = " + cbrtvalue);
 
 
        cbrtvalue = StrictMath.cbrt(val3);
        System.out.println("Cube root of "+val3+
                                  " = " + cbrtvalue);
 
    }
}


Output: 

Cube root of 8.05 = 2.0041580161269152
Cube root of 27.0 = 3.0
Cube root of 0.0 = 0.0

 

Program 2: 

java




// Java program to illustrate the
// java.lang.StrictMath.cbrt()
import java.lang.*;
 
public class Geeks {
 
    public static void main(String[] args)
    {
 
        double val1 = -8.05, val2 = 128, val3 = 0;
 
        // It returns the cube root of a double value
        double cbrtvalue = StrictMath.cbrt(val1);
        System.out.println("Cube root of "+val1+
                                  " = " + cbrtvalue);
 
        cbrtvalue = StrictMath.cbrt(val2);
        System.out.println("Cube root of "+val2+
                                  " = " + cbrtvalue);
 
        cbrtvalue = StrictMath.cbrt(val3);
         System.out.println("Cube root of "+val3+
                                  " = " + cbrtvalue);
 
    }
}


Output: 

Cube root of -8.05 = -2.0041580161269152
Cube root of 128.0 = 5.039684199579493
Cube root of 0.0 = 0.0

 

RELATED ARTICLES

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS