首页 > 其他 > 详细

Math类小结

时间:2017-10-09 17:24:03      阅读:216      评论:0      收藏:0      [点我收藏+]
package com.swift;

public class MathDemo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //数学类的小总结 Math
        System.out.println(Math.pow(4, 3));//幂运算 64
        System.out.println(Math.pow(4, 0.5));//4的开方
        System.out.println(Math.pow(2, -2));//0.25 2的2次幂分之1
        System.out.println(Math.sqrt(16));//0.25 2的2次幂分之1  square root sqrt
        System.out.println(Math.sqrt(25));//0.25 2的2次幂分之1
        System.out.println(Math.abs(-3));//0.25 2的2次幂分之1 absolute
        System.out.println(Math.ceil(2.6));//0.25 2的2次幂分之1 absolute
        System.out.println(Math.ceil(2.1));//0.25 2的2次幂分之1 absolute
        System.out.println(Math.floor(2.1));//0.25 2的2次幂分之1 absolute
        System.out.println(Math.rint(2.1));//0.25 2的2次幂分之1 absolute 返回偶数
        System.out.println(Math.round(2.1));//正数四舍五入,负数五舍六入
    }

}

 

Math类小结

原文:http://www.cnblogs.com/qingyundian/p/7641840.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!