- 舍掉小数取整:Math.floor(3.5)=3 返回不大于的最大整数
- 四舍五入取整:Math.rint(3.5)=4
- 进位取整:Math.ceil(3.1)=4
- 取绝对值:Math.abs(-3.5)=3.5
- 取余数:A%B = 余数
- 四舍五入:Math.round(x) = Math.floor(x + 0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(11.5)的结果为12,Math.round(-11.5)的结果为-11。
Java的运算符-取整,取绝对值,取余数
最新推荐文章于 2023-05-18 08:37:10 发布