java math exp_Java Math类静态double exp(double d)与示例

java math exp

数学类静态double exp(double d) (Math Class static double exp(double d))

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return the exponential of the given number in the method or other words it is used to calculate the e raised to the power of the given argument.

    此方法用于返回该方法中给定数字的指数,或者换句话说,它用于计算提高到给定自变量幂的e。

  • In this method, exp stands for exponentiation.

    在此方法中,exp代表幂。

  • This is a static method so this method is accessible with the class name too.

    这是一个静态方法,因此也可以使用类名访问此方法。

  • The return type of this method is double that means it returns the exponentiation of the given argument and the argument and return value is of double type.

    此方法的返回类型是double,这意味着它返回给定参数的幂,并且该参数和返回值是double类型。

  • In this method we pass only one parameter as an argument in the method of Math class and the given parameter is the exponent to raise the power of e to.

    在此方法中,我们仅将一个参数作为参数传递给Math类的方法,并且给定参数是提高e的幂的指数。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    public static double exp(double d){
    }

Parameter(s):

参数:

double d – A double value whose exponential to be found..

double d –一个要找到其指数的double值。

Note:

注意:

  • If we pass "NaN" to the function, it returns the "NaN".

    如果我们将“ NaN”传递给函数,它将返回“ NaN”。

  • If we pass positive infinity, it returns the positive infinity.

    如果我们传递正无穷大,它将返回正无穷大。

  • If we pass negative infinity, it returns 0.0.

    如果我们传递负无穷大,它将返回0.0。

Return value:

返回值:

The return type of this method is double, it returns the exponentiation of the given value.

此方法的返回类型为double ,它返回给定值的幂。

Java程序演示exp(double d)方法的示例 (Java program to demonstrate example of exp(double d) method)

// Java program to demonstrate the example of 
//exp(double d) method of Math Class

public class ExpMethod {
    public static void main(String[] args) {
        // Here we are declaring few variables
        double d1 = 7.0 / 0.0;
        double d2 = -7.0 / 0.0;
        double d3 = 0.8;
        double d4 = 2;

        // Display previous value of d1,d2,d3 and d4 
        System.out.println(" Before implementing exp() so the value of d1 is :" + d1);
        System.out.println(" Before implementing exp() so the value of d2 is :" + d2);
        System.out.println(" Before implementing exp() so the value of d3 is :" + d3);
        System.out.println(" Before implementing exp() so the value of d4 is :" + d4);

        // Here , we will get (Infinity) because we are 
        // passing parameter whose value is (infinity)
        System.out.println("After implementing exp() so the value of d1 is :" + Math.exp(d1));

        // Here , we will get (0.0) because we are 
        // passing parameter whose value is (-infinity)
        System.out.println("After implementing exp() so the value of d2 is :" + Math.exp(d2));

        // Here , we will get (e raised to the power of 0.8) 
        // because we are passing parameter whose value is (0.8)
        System.out.println("After implementing exp() so the value of d3 is :" + Math.exp(d3));

        // Here , we will get ( e raised to the power of 2) 
        // because we are passing parameter whose value is (2)
        System.out.println("After implementing exp() so the value of d4 is :" + Math.exp(d4));
    }
}

Output

输出量

E:\Programs>javac ExpMethod.java

E:\Programs>java ExpMethod

Before implementing exp() so the value of d1 is :Infinity
Before implementing exp() so the value of d2 is :-Infinity
Before implementing exp() so the value of d3 is :0.8
Before implementing exp() so the value of d4 is :2.0

After implementing exp() so the value of d1 is :Infinity
After implementing exp() so the value of d2 is :0.0
After implementing exp() so the value of d3 is :2.225540928492468
After implementing exp() so the value of d4 is :7.38905609893065


翻译自: https://www.includehelp.com/java/math-class-static-double-exp-double-d-with-example.aspx

java math exp

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值