保留n位小数方法如下:
function GetPreciseDecimal(nNum, n)
if type(nNum) ~= "number" then --判断是不是数字类型
return nNum
end
n = n or 0
n = math.floor(n)--向上取整
if n < 0 then
n = 0
end
local nDecimal = 10 ^ n
local nTemp = math.floor(nNum * nDecimal)
local nRet = nTemp / nDecimal
return nRet
end