Math.round(),Math.ceil(),Math.floor(),Math.pow(x,y)的区别

Math.round()

round 附近 四舍五入 取附近的整数

Math.round(11.5)=12
Math.round(11.4)=11
Math.round(-11.6)=-12
Math.round(-11.4)=-11

Math.ceil()

ceil 天花板 取大于当前小数的整数

Math.ceil(11.2)=12
Math.ceil(-11.5)=-11

Math.floor()

floor 地板 取小于当前小数的整数

Math.floor(11.5)=11
Math.floor(-11.5)=-12

Math.pow(x,y)

x的y次幂

Math.pow(-2,3)=-8
Math.pow(2,3) =8

😊

posted @ 2019-12-10 17:49  Amy小影儿  阅读(339)  评论(0编辑  收藏  举报