美文网首页
Javascript Math ceil()、floor()、r

Javascript Math ceil()、floor()、r

作者: 年年_0273 | 来源:发表于2018-04-17 20:31 被阅读0次

ceil():将小数部分一律向整数部分进位。
如:

Math.ceil(12.2)//返回13 
Math.ceil(12.7)//返回13 
Math.ceil(12.0)// 返回12 

floor():一律舍去,仅保留整数。
如:

Math.floor(12.2)// 返回12 
Math.floor(12.7)//返回12 
Math.floor(12.0)//返回12 

round():进行四舍五入
如:

Math.round(12.2)// 返回12 
Math.round(12.7)//返回13 
Math.round(12.0)//返回12

相关文章

网友评论

      本文标题:Javascript Math ceil()、floor()、r

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