Java->Math类

来源:互联网 发布:js获取所有input的值 编辑:程序博客网 时间:2024/05/21 07:10
//绝得值
Math.abs(-0.6);
//最大整数
Math.ceil(0.3);
//最小整数
Math.floor(0.6);
//最大数
Math.max(5, 8);
//最小数
Math.min(5, 8);
//pi
System.out.println(Math.PI);
//4的5次幂
Math.pow(4,5);
//正开方根
Math.sqrt(4);
//最接近参数并等于某一整数(5的时候取偶数:0.5-》0;1.5,2.5-》2;3.5-》4)
Math.rint(5.4);
//随机数
Math.random();
0 0
原创粉丝点击