All pastes #1311294 Raw Edit

Unnamed

public lua v1 · immutable
#1311294 ·published 2009-01-18 01:22 UTC
rendered paste body
function 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