Java中的StrictMath expm1()方法及其示例

爪哇。朗,数学。expm1()是Java中的一个内置方法,用于返回 指数e^num-1 对于给定的 号码 .该方法产生了四种不同的情况:

null
  • 当给定参数为NaN时,该方法返回NaN。
  • 当参数为正无穷大时,结果为正无穷大。
  • 当参数为负无穷大时,结果为负无穷大。
  • 对于0,方法返回与参数符号相同的0。

语法:

public static double expm1(double num)

参数: 此方法接受一个参数 号码 指要对其执行指数运算的值。 返回值: 该方法将返回 E 号码 – 1 活动 例如:

Input: num = (1.0/0.0)Output: InfinityInput: 32.2Output: 9.644557735961714E13

下面的程序演示了java。朗,数学。expm1()方法: 项目1:

JAVA

// Java program 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

// Java program 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);
}
}


© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享