Home >>Java Math Methods >Java Math.cbrt() method

Java Math.cbrt() method

Java Math.cbrt() method

The java.lang. Math.cbrt() in Java Math is used to helps to return a number's cube root.

Syntax

public static double cbrt(double x)

Parameters

x=This parameter is ued to paq a value

Returns

This method returns the cube root of x.

  1. If the statement is double positive or negative, this method returns the cube root of a given value.
  2. This method returns -1 if the statement is -1.
  3. This method must return Infinity with the same sign as the argument if the argument is infinity.
  4. This procedure will return Zero with the same sign as the argument if the argument is positive or negative Zero.

Java Math.cbrt() Method Example 1


public class MyClass
{  
    public static void main(String[] args)   
    {  
        double x = 525;  
        System.out.println(Math.cbrt(x));  
    }  
}  

Output:
8.067143230122719

Java Math.cbrt() Method Example 2


public class MyClass 
{  
    public static void main(String[] args)   
    {  
        double a = 1.0/0;  
        System.out.println(Math.cbrt(a));  
    }  
}  

Output:
Infinity

No Sidebar ads