1、Math.ceil(5.2) = 6.0向上取整 对应的是Math.floor(5.6) = 5.0 向下取整
2、Math.rint(5.5) = 5.0 Math.rint(5.6) = 6.0 Math.rint(5.1) = 5.0
3、Math.round(5.5) = 6 常规的四舍五入 取整
1、Math.ceil(5.2) = 6.0向上取整 对应的是Math.floor(5.6) = 5.0 向下取整
2、Math.rint(5.5) = 5.0 Math.rint(5.6) = 6.0 Math.rint(5.1) = 5.0
3、Math.round(5.5) = 6 常规的四舍五入 取整
本文标题:java取整方法
本文链接:https://www.haomeiwen.com/subject/azfzkxtx.html
网友评论