round()方法Java

round()方法-Java

// round()是四舍五入的计算,五入时是到大于它的整数
Math.round(3.7) // 4
// 底层算法是:Math.floor(x+0.5) ,将原来的数字加0.5再向下取整
Math.round(11.5) // 12
Math.rounf(-11.5) // -11

猜你喜欢

转载自blog.csdn.net/E_chos/article/details/114641786