关于js的向上取整、向下取整、四舍五入

Math.floor(5.55) //向下取整 结果为5 
Math.floor(5.99) //向下取整 结果为5 
Math.ceil(5.21) //向上取整,结果为6 
Math.ceil(5.88) //向上取整,结果为6 
Math.round(5.78) //四舍五入 结果为6 
Math.round(5.33) //结果为5

 

posted @ 2022-01-25 12:25  Jim-vue  阅读(1028)  评论(0编辑  收藏  举报