Math类方法

Math类方法

public class SummaryMath {
    public static void main(String[] args) {
        //1.求绝对值
        int abs = Math.abs(-12);
        //2.最大值
        int max = Math.max(12, 99);
        //3.最小值
        int min = Math.min(465, 8);
        //求整运算
        //4.返回大于或等于的最小整数
        int ceil = (int)(Math.ceil(45.4));
        //5.返回小于或等于的最大整数
        int floor = (int)Math.floor(-66.3);
        //6.返回最接近的整数值,如果有两个同样接近的整数,则结果取偶数
        int rint = (int)Math.rint(88.8);
        //7.将参数加上1/2后返回最接近的整数
        long round = Math.round(65.1);
        //三角函数运算
        double sin = Math.sin(Math.PI);
        double cos = Math.cos(Math.PI);
        double asin = Math.asin(1);
        double acos = Math.acos(1);
        double tan = Math.tan(Math.PI);
        double atan = Math.atan(1);
        //指数运算
        //返回e的多少次幂
        double exp = Math.exp(2);
        double pow = Math.pow(12, 8584);
        double sqrt = Math.sqrt(36);
        double cbrt = Math.cbrt(8);
        double log = Math.log(2);
        double v = Math.log10(12);
        //随机数(0~1.0)
        double random = Math.random();
        


    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值