package cn.meowrain.Math;

public class math {
    public static void main(String[] args) {
        //1. abs绝对值
        int abs = Math.abs(-19);
        System.out.println(abs);
        //2.pow求幂
        double pow = Math.pow(2, 3);
        System.out.println(pow);
        //3.ceil向上取整
        double ceil = Math.ceil(3.1);
        System.out.println(ceil);
        //4.floor向下取整
        double floor = Math.floor(3.6);
        System.out.println(floor);
        //5.round四舍五入
        double round1 = Math.round(3.4);
        double round2 = Math.round(3.6);
        StringBuffer str = new StringBuffer();
        str.append("the round 1 :").append(round1);
        str.append("\n").append("the round2 :").append(round2);
        System.out.println(str);
        //6.sqrt求开平方
        double sqrt = Math.sqrt(16);
        System.out.println(sqrt);
        //7. random 求随机数
        //random 返回随机数  0<=x<1
        //如果想去到 2 - 7的随机数
        double random = Math.random();
        int num = (int)((random)*6+2);
        System.out.println(num);

        //max求两个数的最大值
        //min求两个数的最小值
        int a = 10;
        int b = 20;
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        System.out.println("max :" + max + "\n" + "min :" + min);

    }
}