Java StrictMath exp()方法

Java StrictMath exp()方法

java.lang.StrictMath.exp() 是Java中的一个内置方法,用于返回一个提升到指定双倍值的欧拉数。它产生了三个特殊的结果。

  • 当给定的参数是正无穷大时,其结果是正无穷大。
  • 当参数是负无穷大时,结果是正零。
  • 当给定参数为NaN时,结果为NaN。

语法:

public static double exp( _double num_ )

参数: 该方法接受一个参数 num ,该参数为双倍类型,是将e提高到的指数。
返回值: 该方法返回值e^num,其中e是自然对数的基数。
示例

Input: num = 7
Output: 1096.6331584284585

Input: num = (1.0 / 0.0)
Output: Infinity

下面的程序说明了java.lang.StrictMath.exp()方法:
程序1

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程