一. 小数取整函数
ceil() 将小数部分一律向整数部分进位:
Math.ceil(12.2)//返回13Math.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
待续。。。。。
小数取整函数详解
本文详细介绍了三种常用的小数取整函数:向上取整函数ceil()、向下取整函数floor()以及四舍五入函数round()。通过具体的示例说明了这三种函数在处理小数时的不同行为。
1万+

被折叠的 条评论
为什么被折叠?



