java.lang.StrictMath類的所有方法:設置1,設置2 java.lang.StrictMath.exp()是Java中的一種內置方法,用於返回歐拉數,該歐拉數提高為指定的雙精度值的冪。它產生三個特殊結果:
- 當給定參數為正無窮大時,結果為正無窮大。
- 當參數為負無窮大時,結果為正零。
- 當給定參數為NaN時,結果為NaN。
用法:
public static double exp(double num)
參數:此方法接受一個雙精度類型的參數num,它是將e提高到的 index 。
返回值:該方法返回值e^num,其中e是自然對數的底數。
例子:
Input:num = 7 Output:1096.6331584284585 Input:num = (1.0 / 0.0) Output:Infinity
下麵的程序演示了java.lang.StrictMath.exp()方法:
程序1:
// Java praogram to illustrate the
// java.lang.StrictMath.exp()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = 0.0, num2 = (1.0 / 0.0);
double num3 = 4;
// Returns Euler's number e raised to the given power
double expValue = StrictMath.exp(num1);
System.out.println("The exp value of "+
num1+" = " + expValue);
expValue = StrictMath.exp(num2);
System.out.println("The exp value of "+
num2+" = " + expValue);
expValue = StrictMath.exp(num3);
System.out.println("The exp value of "+
num3+" = " + expValue); }
}
輸出:
The exp value of 0.0 = 1.0 The exp value of Infinity = Infinity The exp value of 4.0 = 54.598150033144236
程序2:
// Java praogram to illustrate the
// java.lang.StrictMath.exp()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = -0.0, num2 = (1.0 / 0.0);
double num3 = 14;
// Returns Euler's number e raised to the given power
double expValue = StrictMath.exp(num1);
System.out.println("The exp value of "+
num1+" = " + expValue);
expValue = StrictMath.exp(num2);
System.out.println("The exp value of "+
num2+" = " + expValue);
expValue = StrictMath.exp(num3);
System.out.println("The exp value of "+
num3+" = " + expValue);
}
}
輸出:
The exp value of -0.0 = 1.0 The exp value of Infinity = Infinity The exp value of 14.0 = 1202604.2841647768
相關用法
- Java StrictMath log()用法及代碼示例
- Java StrictMath pow()用法及代碼示例
- Java StrictMath sin()用法及代碼示例
- Java StrictMath tan()用法及代碼示例
- Java StrictMath random()用法及代碼示例
- Java StrictMath hypot()用法及代碼示例
- Java StrictMath atan2()用法及代碼示例
- Java StrictMath max()用法及代碼示例
- Java StrictMath rint()用法及代碼示例
- Java StrictMath round()用法及代碼示例
- Java StrictMath multiplyExact()用法及代碼示例
- Java StrictMath nextDown()用法及代碼示例
- Java StrictMath sinh()用法及代碼示例
- Java StrictMath tanh()用法及代碼示例
- Java StrictMath scalb()用法及代碼示例
注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StrictMath exp() Method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。