Math.ceil()和Math.floor()、Math.round()截断数字的两个函数,主要任务是截掉小数以后的位数。
区别是:ceil()总是把数字变得越来越大,而floor()总是把数字变得越来越小,Math.round()是采用四舍五入方式取得最接近的整数。
Math.ceil()和Math.floor()、Math.round()
最新推荐文章于 2024-03-16 14:26:22 发布
Math.ceil()和Math.floor()、Math.round()截断数字的两个函数,主要任务是截掉小数以后的位数。
区别是:ceil()总是把数字变得越来越大,而floor()总是把数字变得越来越小,Math.round()是采用四舍五入方式取得最接近的整数。