js中Math.floor(),Math.round(),Math.ceil()
1、Math.floor() ,Math.round()方法执行的是取整计算,它们得到的是与之最接近的整数当参数没有的时候,返回你NaNMath.floor()NaNMath.round()NaN

2、我们再使用Math.floor()传入其它参数看看,如下所示。可以看出返回的都是比它小的,最接近它的整数Math.floor(2.9)2Math.floor(-2.9)-3Math.floor(-0.5)-1Math.floor(-0.9)-1Math.floor(0.9)0Math.floor(1.9)1

4、ceil() 方法是向上取整计算,它返回的是大于或等于参数的整数数据同样Math.ceil()没传入参数也是返回NaNMath.ceil()NaN

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:42
阅读量:29
阅读量:75
阅读量:36
阅读量:96