math类

math类是私有的类,直接使用类名.方法调用方法,常见方法:

Math.abs(-12);//取绝对值
double i = Math.random() * 900 + 100;
Math.max(10,30);//取最大值
Math.min(20,78);//取最小值
Math.pow(2,9);//2的9次方
System.out.println(Math.round(5.5));//四舍五入6
System.out.println(Math.floor(5.5));//向下取整5.0
System.out.println(Math.ceil(5.5));//向上取整6.0
posted @ 2022-10-31 10:34  Liku007  阅读(17)  评论(0编辑  收藏  举报