返回列表 发帖

lua 取一个数字的整数部分(我不水?)

  1. function getIntPart(x)
  2.    if x <= 0 then
  3.       return math.ceil(x);
  4.    end
  5.    if math.ceil(x) == x then
  6.       x = math.ceil(x);
  7.    else
  8.      x = math.ceil(x) - 1;
  9.    end
  10.    return x;
  11. end
复制代码
我是流氓我怕谁

返回列表