目录

static double exp(double a)

描述 (Description)

java.lang.StrictMath.exp()方法将Euler's number e提升为double值的幂。它包括这些情况 -

  • 如果参数是NaN,则结果为NaN。
  • 如果参数是正无穷大,那么结果是正无穷大。
  • 如果参数为负无穷大,则结果为正零。

声明 (Declaration)

以下是java.lang.StrictMath.exp()方法的声明

public static double exp(double a)

参数 (Parameters)

a - 这是将e提升到的指数。

返回值 (Return Value)

此方法返回值e a ,其中e是自然对数的基数。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.StrictMath.exp()方法的用法。

package com.iowiki;
import java.lang.*;
public class StrictMathDemo {
   public static void main(String[] args) {
      double d1 = 0.0 , d2 = -0.0, d3 = (1.0/0.0), d4 = 5;
      // returns Euler's number e raised to the power positive 0 
      double eulerValue = StrictMath.exp(d1); 
      System.out.println("Euler value of d1 = " + eulerValue);
      // returns Euler's number e raised to the power negative 0
      eulerValue = StrictMath.exp(d2); 
      System.out.println("Euler value of d2 = " + eulerValue);
      // returns Euler's number e raised to the power infinity
      eulerValue = StrictMath.exp(d3);
      System.out.println("Euler value of d3 = " + eulerValue);
      // returns Euler's number e raised to the power 5
      eulerValue = StrictMath.exp(d4);
      System.out.println("Euler value of d4 = " + eulerValue);
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Euler value of d1 = 1.0
Euler value of d2 = 1.0
Euler value of d3 = Infinity
Euler value of d4 = 148.4131591025766
↑回到顶部↑
WIKI教程 @2018