javascript除法如何取整

时间:2014-07-01 23:01:14   收藏:0   阅读:303

Math.round(x) 四舍五入,如Math.round(0.60),结果为1;Math.round(0.49),结果为0;

Math.floor(x) 向下舍入,如Math.floor(0.60)与Math.floor(0.49),结果均为0;

Math.ceil(x)向上舍入,如Math.ceil(0.60)与Math.ceil(0. 49),结果均为1。

javascript除法如何取整,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!