1、向上取整:math.ceiling()
例如:math.ceiling(1) = 1
math.ceiling(1.1) = 2
math.ceiling(1.5) = 2
2、向下取整:math.floor()
例如:math.floor(1) = 1
math.floor(1.1) = 1
math.floor(1.5) = 1
3、四舍五入(四舍六入五取偶): Math.Round()
例如:Math.Round(0.5,0)=0
Math.Round(1.5,0)=2
Math.Round(2.5,0)=2
Math.Round(3.5,0)=4
准确的说,不是四舍五入,而是四舍六入无凑偶,就是说小于4大于6该舍就舍该入就入,没有争议,而无处于正中间,如果四舍五入会造成数据整体偏差,所以采取的原则是:如果舍入位为5,就去最近的偶数。
4、 直接切下整数trunc
例如:比如 trunc(-123.55)=-123, floor(123.55)=123
5、返回绝对值:math.abs()