Unnamed
public lua v1 · immutablefunction FormatNbr(x,digits) local _,fractional = math.modf(x) if fractional==0 then return x elseif fractional<0.01 then return math.floor(x) elseif fractional>0.99 then return math.ceil(x) else local ret=string.format("%."..(digits or 0).."f",x) while true do local last = string.sub(ret,string.len(ret)) if last=="0" or last=="." then ret = string.sub(ret,1,string.len(ret)-1) end if last~="0" then break end end return ret endend