周一至周日9:00-22:00
Math.round(11.5)等於多少? Math.round(-11.5)等於多少?
Math.round(11.1)等於多少?
Math.round(11.5)==12.0
Math.round(-11.5)==-11.0
Math.round(11.1)==11.0
本质是加0.5然后向下取整
Math.round(11.5)=12
Math.round(-11.5)=11
Math.round(11.1)=11
返回一个最接近的值,如果是0.5最向正无穷方向取值
round方法,他表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整
Math.round(-11.5)=-11
Math.round(11.5)==12.0
Math.round(-11.5)==-11.0
Math.round(11.1)==11.0
本质是加0.5然后向下取整