Math中的floor,round和ceil方法总结

floor向下取整,返回不大于的最大整数  Math.floor(1.4)=1.0
ceil向上取整,返回不小于的最小整数  Math.ceil(1.4)=2.0
round 四舍五入,将原来的数字加入0.5后再向下取整
Math.round(-1.4)=-1   Math.round(-1.5)=-1  Math.round(-1.6)=-2

原文地址:https://www.cnblogs.com/zhaobao1830/p/6340495.html