美文网首页
Math .ceil()/Math.floor()/Math.r

Math .ceil()/Math.floor()/Math.r

作者: YoungEvita | 来源:发表于2018-03-18 21:21 被阅读0次

1. Math.ceil(x) 向上取整
2. Math.floor(x) 向下取整
3. Math.round(x) 四舍五入取整。等价于 Math.floor(x+0.5);

Math.ceil(11.1); \\ 12
Math.ceil(11.5); \\ 12
Math.ceil(11.6); \\12
Math.ceil(-11.1); \\ -11
Math.ceil(-11.5); \\ -11
Math.ceil(-11.6); \\ -11

Math.floor(11.1); \\ 11
Math.floor(11.5); \\ 11
Math.floor(11.6) \\ 11
Math.floor(-11.1) \\ -12
Math.floor(-11.5); \\ -12
Math.floor(-11.6); \\ -12

Math.round(11.1); \\ 11
Math.round(11.5); \\ 12
Math.round(11.6); \\ 12
Math.round(-11.1); \\ -11
Math.round(-11.5); \\ -11
Math.round(-11.6); \\ -12

相关文章

网友评论

      本文标题:Math .ceil()/Math.floor()/Math.r

      本文链接:https://www.haomeiwen.com/subject/swsyqftx.html