strictmath_Java StrictMath pow()方法与示例

strictmath

StrictMath类pow()方法 (StrictMath Class pow() method)

  • pow() method is available in java.lang package.

    pow()方法在java.lang包中可用。

  • pow() method is used to calculate the power of the given arguments or in other words, it returns the value of the first parameter raised to the power of the second parameter.

    pow()方法用于计算给定参数的幂,换句话说,它将第一个参数的值返回为第二个参数的幂。

  • pow() method is a static method and it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

    pow()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • pow() method does not throw any exception at the time of calculating the power of the given arguments.

    pow()方法在计算给定参数的功效时不会引发任何异常。

Syntax:

句法:

    public static double pow(double base , double exponent);

Parameter(s):

参数:

  • base – represents the base.

    base –代表基数。

  • exponent – represents the power (exponent).

    指数 –表示幂(指数)。

Return value:

返回值:

The return type of this method is double – it returns the base raised to the power of exponent.

此方法的返回类型为double-将返回的底数返回指数幂。

Note:

注意:

  • If we pass NaN as the first argument and a non-zero value as the second argument, the method returns NaN.

    如果我们将NaN作为第一个参数传递,并将非零值作为第二个参数传递,则该方法将返回NaN。

  • If we pass NaN as the second argument, the method returns NaN.

    如果我们将NaN作为第二个参数传递,则该方法将返回NaN。

  • If we pass 1.0 as the second argument, the method returns the value of the first argument.

    如果我们将1.0作为第二个参数传递,则该方法将返回第一个参数的值。

  • If we pass 0 (native or positive) as the second argument, the method returns 1.0.

    如果我们将0(正数或正数)作为第二个参数传递,则该方法返回1.0。

Example:

例:

// Java program to demonstrate the example of 
// pow(double base , double exponent) method of StrictMath Class.

public class Pow {
    public static void main(String[] args) {
        // Variable Declarations
        double d1 = 2.0;
        double d2 = 3.0;
        double d3 = 4.0;
        double d4 = 6.0;

        // Here , we will get (d1 raised to the power of d2) 
        // because we are passing parameter (2.0,3.0) 
        System.out.println("StrictMath.pow(d1,d2): " + StrictMath.pow(d1, d2));

        // Here , we will get (d3 raised to the power of d4) 
        // because we are passing parameter (4.0,6.0) 
        System.out.println("StrictMath.pow(d3,d4): " + StrictMath.pow(d3, d4));
    }
}

Output

输出量

StrictMath.pow(d1,d2): 8.0
StrictMath.pow(d3,d4): 4096.0


翻译自: https://www.includehelp.com/java/strictmath-pow-method-with-example.aspx

strictmath

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值