Math.ceil()和Math.floor()、Math.round()

来源:互联网 发布:2017北京人口分布数据 编辑:程序博客网 时间:2024/04/30 18:12

Math.ceil()和Math.floor()、Math.round()截断数字的两个函数,主要任务是截掉小数以后的位数。
区别是:ceil()总是把数字变得越来越大,而floor()总是把数字变得越来越小,Math.round()是采用四舍五入方式取得最接近的整数。

原创粉丝点击