java.lang.StrictMath.cbrt()是Java中的內置方法,用於返回給定double值的多維數據集根。該方法顯示三個特殊結果:
- 當給定參數為零時,結果為零,其符號與參數相同。
- 當參數為無窮大時,結果為無窮大且帶有相同的參數。
- 當給定參數為NaN時,結果為NaN。
用法:
public static double cbrt(double num)
參數:此方法接受一個參數num,該參數為double類型,需要找到其立方根。
返回值:該方法返回num的立方根。
下麵的程序演示了java.lang.StrictMath.cbrt()方法:
示例1:
// Java praogram 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);
}
}
輸出:
Cube root of 8.05 = 2.0041580161269152 Cube root of 27.0 = 3.0 Cube root of 0.0 = 0.0
示例2:
// Java praogram 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);
}
}
輸出:
Cube root of -8.05 = -2.0041580161269152 Cube root of 128.0 = 5.039684199579493 Cube root of 0.0 = 0.0
相關用法
- Java cbrt()用法及代碼示例
- Java StrictMath tan()用法及代碼示例
- Java StrictMath pow()用法及代碼示例
- Java StrictMath exp()用法及代碼示例
- Java StrictMath log()用法及代碼示例
- Java StrictMath sin()用法及代碼示例
- Java StrictMath sinh()用法及代碼示例
- Java StrictMath log1p()用法及代碼示例
- Java StrictMath log10()用法及代碼示例
- Java StrictMath toRadians()用法及代碼示例
- Java StrictMath toDegrees()用法及代碼示例
- Java StrictMath scalb()用法及代碼示例
- Java StrictMath hypot()用法及代碼示例
- Java StrictMath fma()用法及代碼示例
- Java StrictMath multiplyExact()用法及代碼示例
注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StrictMath cbrt() Method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。