lua-users home
lua-l archive

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


> -- convert big or small number in scientific notation into a decimal string

Why not something like this?

function xtostring(x)
	local f=string.format
	for k=0,99 do
		local s=f("%."..k.."f",x)
		local y=tonumber(s)
		if y==x then return s,k end
	end
end

The main limitation is that string.format does not allow more than %.99f.