Math类小结

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));//正数四舍五入,负数五舍六入
    }

}
原文地址:https://www.cnblogs.com/qingyundian/p/7641840.html