Java中Math pow 的使用

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

                       

public class text 
{
    public static void main(String[] args)
     {
         double sum=0;
         for(int i=2;i<=10;i++)
         {
         sum=sum+1.0/i;
         }
        System.out.println(sum);
        System.out.println((int)Math.pow(10.0, 2.0));
    }
}
这段代码中重要的代码如下:
 System.out.println((int)Math.pow(10.0, 2.0));
 求的是10的平方,(int)主要使得结果是整形

例:
d = (int)Math.pow(a, 2)*(int)Math.pow(b, 2);
这个主要是Math.pow(a,b)的使用方法,求a的b次方,然后相乘。

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_43679940/article/details/84105929
pow