微智科技网
您的当前位置:首页js中取整方法的比较

js中取整方法的比较

来源:微智科技网


Math.ceil():向上取整

Math.floor():向下取整

Math.round():四舍五入

需要注意的比如:Math.ceil(-1.6) = -1.0;

Math.round(-1.5) = -1;

Math.round(-1.6) = -2;

显示全文