java expextion_Java Math exp()用法及代码示例

java.lang.Math.exp()返回欧拉数e,该数字e增大为双精度值的幂。

如果参数为NaN,则结果为NaN。

如果参数为正无穷大,则结果为正无穷大。

如果参数为负无穷大,则结果为正零。

用法:

public static double exp(double a)

Parameter:

a:the exponent part which raises to e.

返回值:

值ea,其中e是自然对数的底数。

例:演示java.lang.Math.exp()函数的工作

// Java program to demonstrate working

// of java.lang.Math.exp() method

import java.lang.Math;

class Gfg {

// driver code

public static void main(String args[])

{

double x = 3;

// when both are not infinity

double result = Math.exp(x);

System.out.println(result);

double positiveInfinity =

Double.POSITIVE_INFINITY;

double negativeInfinity =

Double.NEGATIVE_INFINITY;

double nan = Double.NaN;

// when 1 is NAN

result = Math.exp(nan);

System.out.println(result);

// when one argument is +INF

result = Math.exp(positiveInfinity);

System.out.println(result);

result = Math.exp(negativeInfinity);

System.out.println(result);

}

}

输出:

20.085536923187668

NaN

Infinity

0.0

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值