java.lang.StrictMath.expm1()是Java中的內置方法,用於為給定的num值返回指數e^num -1。該方法產生四種不同的情況:
- 當給定參數為NaN時,該方法返回NaN。
- 當參數為正無窮大時,結果為正無窮大。
- 當參數為負無窮大時,結果為負無窮大。
- 對於0,方法返回0,並帶有與參數相同的符號。
用法:
public static double expm1(double num)
參數:此方法接受一個雙精度類型的參數num,表示要對其執行指數運算的值。
返回值:該方法將返回enum – 1操作的結果。
例子:
Input: num = (1.0/0.0) Output: Infinity Input: 32.2 Output: 9.644557735961714E13
以下示例程序旨在說明java.lang.StrictMath.expm1()方法:
示例1:
// Java praogram to illustrate the
// java.lang.StrictMath.expm1()
import java.lang.*;
public class Geeks {
public static void main(String[] args) {
double num1 = 0.0, num2 = -(1.0/0.0);
double num3 = (1.0/0.0), num4 = 32.2;
/*It returns e^num - 1 */
double eValue = StrictMath.expm1(num1);
System.out.println("The expm1 Value of "+
num1+" = "+eValue);
eValue = StrictMath.expm1(num2);
System.out.println("The expm1 Value of "+
num2+" = "+eValue);
eValue = StrictMath.expm1(num3);
System.out.println("The expm1 Value of "+
num3+" = "+eValue);
eValue = StrictMath.expm1(num4);
System.out.println("The expm1 Value of "+
num4+" = "+eValue);}
}
示例2:
// Java praogram to illustrate the
// java.lang.StrictMath.expm1()
import java.lang.*;
public class Geeks {
public static void main(String[] args) {
double num1 = 2.0 , num2 = -51.8;
double num3 = 61.0, num4 = -32.2;
/*It returns e^num - 1 */
double eValue = StrictMath.expm1(num1);
System.out.println("The expm1 Value of "+
num1+" = "+eValue);
eValue = StrictMath.expm1(num2);
System.out.println("The expm1 Value of "+
num2+" = "+eValue);
eValue = StrictMath.expm1(num3);
System.out.println("The expm1 Value of "+
num3+" = "+eValue);
eValue = StrictMath.expm1(num4);
System.out.println("The expm1 Value of "+
num4+" = "+eValue);
}
}
相關用法
- Java StrictMath fma()用法及代碼示例
- Java StrictMath cos()用法及代碼示例
- Java StrictMath max()用法及代碼示例
- Java StrictMath min()用法及代碼示例
- Java StrictMath ulp()用法及代碼示例
- Java StrictMath ceil()用法及代碼示例
- Java StrictMath multiplyFull()用法及代碼示例
- Java StrictMath asin()用法及代碼示例
- Java StrictMath toIntExact()用法及代碼示例
- Java StrictMath multiplyHigh()用法及代碼示例
- Java Math expm1()用法及代碼示例
- Java StrictMath subtractExact()用法及代碼示例
- Java StrictMath pow()用法及代碼示例
- Java StrictMath exp()用法及代碼示例
- Java StrictMath log()用法及代碼示例
注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StrictMath expm1() Method in Java With Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。