lua实现一个小数取整数部分

来源:互联网 发布:淘宝创始人是谁 编辑:程序博客网 时间:2024/05/18 02:27
--取一个数的整数部分
function getIntPart(x)
    if x<= 0 then
        return math.ceil(x)
    end
    if math.ceil(x) == x then
        x = math.ceil(x)
    else
        x = math.ceil(x)-1
    end


    return x
end
0 0
原创粉丝点击