lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


function round(x)
  return math.floor(x+0.5)
end

round(x) -- 100500


发件人: lua-l-bounces@lists.lua.org <lua-l-bounces@lists.lua.org> 代表 涵曦 <hanxi.info@gmail.com>
发送时间: 2016年7月29日 1:06
收件人: lua-l
主题: Rounding a number to integer
  

Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> 100000*1.005
100500.0
> math.floor(100000*1.005)
100499


I want a function like math.round.


> math.round(100000*1.005)
100500


Have some good idea?