java的math类pow_Java Math类静态double pow(double base,double exponent)的示例

news/2024/5/19 4:01:02 标签: java, python, jvm, jdk, 反射

java的math类pow

数学类静态双战俘(双基,双指数) (Math Class static double pow(double base , double exponent) )

  • This method is available in java.lang package.

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

  • This 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.

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

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

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

  • The return type of this method is double, it returns the power of the given parameters.

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

  • In this method, we pass two parameters, and here the first parameter represents the base value and the second parameter represents the exponent value.

    在此方法中,我们传递了两个参数,这里的第一个参数代表基值,第二个参数代表指数值。

  • This method does not throw any exception.

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

Syntax:

句法:

    public static double pow(double base , double exponent){
    }

Parameter(s):

参数:

  • base – a double value to represent the base.

    base –一个代表基数的双精度值。

  • exponent – a double value to represent the exponent/power.

    指数 –代表指数/ 功效的双精度值。

Return value:

返回值:

The return type of this method is double, it returns the base to the power exponent as a result.

此方法的返回类型为double ,结果将底数返回到幂指数。

Note:

注意:

  • If the base is "NaN" (Not a Number) and the exponent is non-zero), it returns the "NaN".

    如果基数是“ NaN”(不是数字)并且指数不为零,则返回“ NaN”。

  • If the exponent is "NaN", it returns the "NaN".

    如果指数是“ NaN”,则返回“ NaN”。

  • If the exponent value is 1.0, it returns the base value.

    如果指数值为1.0,则返回基值。

  • If the exponent value is 0.0, it returns the 1.0.

    如果指数值为0.0,则返回1.0。

  • If the base is -0.0 and exponent is a finite odd number, it returns the -0.0.

    如果基数是-0.0,指数是有限的奇数,则返回-0.0。

  • If the base is negative infinity and exponent is less than 0 but not a finite odd integer, it returns the 0.0.

    如果基数为负无穷大且指数小于0但不是有限的奇数整数,则返回0.0。

  • If the base is -0 and exponent is a positive finite odd integer, it returns -0.0.

    如果基数为-0,指数为正有限奇数整数,则返回-0.0。

  • If the base negative infinity and exponent is a negative finite odd integer, it returns -0.0.

    如果基本负无穷大和指数是负有限奇数整数,则返回-0.0。

  • If the base is -0 and exponent is less than but not a finite odd integer, it returns the infinity.

    如果基数为-0并且指数小于但不是有限的奇数整数,则返回无穷大。

  • If the base is negative infinity and exponent is greater than 0 but not a finite odd integer, it returns the infinity.

    如果基数为负无穷大且指数大于0但不是有限的奇数整数,则返回无穷大。

  • If the base is negative infinity and exponent is a finite odd integer, it returns the negative infinity.

    如果基数为负无穷大且指数为有限奇数整数,则返回负无穷大。

Java程序演示pow(double base,double exponent)方法的示例 (Java program to demonstrate example of pow(double base , double exponent) method)

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

public class PowMethod {
    public static void main(String[] args) {
        // declaring the variables
        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("Math.pow(d1,d2): " + Math.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("Math.pow(d3,d4): " + Math.pow(d3, d4));
    }
}

Output

输出量

E:\Programs>javac PowMethod.java

E:\Programs>java PowMethod
Math.pow(d1,d2): 8.0
Math.pow(d3,d4): 4096.0


翻译自: https://www.includehelp.com/java/math-class-static-double-pow-double-base-double-exponent-with-example.aspx

java的math类pow


http://www.niftyadmin.cn/n/1256409.html

相关文章

shell两个数字相乘_使用逻辑指令将两个8位数字相乘

shell两个数字相乘Problem statement: 问题陈述: To perform multiplication operation between two 8 bits numbers using logical instructions on 8085 microprocessor. 使用8085微处理器上的逻辑指令在两个8位数字之间执行乘法运算。 Algorithm: 算法&#xf…

matlab中白噪声模拟,噪声产生器的MATLAB实现及性能分析--噪声带宽为1.7MHz仿真噪声产生器。利用m序列模拟高斯白噪声送入一带...

噪声产生器的MATLAB实现及性能分析--噪声带宽为1.7MHz仿真噪声产生器。利用m序列模拟高斯白噪声送入一带mip版 关注:236 答案:2 悬赏:80解决时间 2021-01-26 23:12已解决2021-01-26 00:22噪声产生器的MATLAB实现及性能分析--噪声带宽为1.7MHz仿真噪声产生器。利用m序列模拟高…

数据库模型中层次模型_层次数据库模型中的数据定义和完整性约束

数据库模型中层次模型分层数据库模型 (Hierarchical database model) In the database management system, a Hierarchical database model is a data model in which data are organized in a way of tree-like structure. The data in the database are stored in the form o…

matlab任意去除两列,100*100的矩阵,抽取所有任意两列的数据,怎么办

本帖最后由 ZHONGPF1994 于 2014-7-25 22:50 编辑为便于演示,我仅仅演示了一个10*10的矩阵,你可以吧10换成100即可;(该结果提取的是第10和第8列)>> Arand(10,10)A Columns 1 through 50.9085 0.6069 0.1091 0.4146 0.66840…

小程序验证用户名密码_C程序通过验证用户名和密码设计登录屏幕

小程序验证用户名密码Read username and password and check it with the given values (just like, login screen) using C program. 读取用户名和密码,并使用C程序以给定的值(就像登录屏幕一样)对其进行检查。 In this program we will design a login screen to…

图片管理系统空间 php,自建图片网站 27款开源图片相册管理系统

谷歌贴图可以让用户从互联网搜索图片或从用户的谷歌相册选取图片插入到Discuz论坛,从而提高用户贴图的体验。 用户还可将本地照片批量上传到谷歌相册后插入论坛,达到节省网站空间的目的。phpGraphy这个相册管理系统:支持实时生成缩略图/低分辩…

c ++类指针与类对象转化_在C ++中的另一个类声明中创建一个类的对象

c 类指针与类对象转化As we know that a class contains data members and member function, and an object can also be a data member for another class. 我们知道一个类包含数据成员和成员函数 ,而一个对象也可以是另一个类的数据成员。 Here, in the given pr…

webpack+vue+php,webpack+vue项目实战(二,开发管理系统主页面)

1.前言上篇文章(webpackvue项目实战(一,搭建运行环境和相关配置))搭建了好了基本的一个项目目录,安好好了一些要用到的依赖,以及把项目跑了起来。接下来,我们就进行第二步的操作,第二步就是做好一个开发系统的主页面,这…