Commits

Jérôme Vuarand committed 736ba0e

Fixed serialization of numbers with lots of digits.

Comments (0)

Files changed (1)

 			return write('1/0')
 		elseif v==-1/0 then -- -inf
 			return write('-1/0')
+		elseif v==math.floor(v) then
+			return write(tostring(v))
 		else
-			return write(tostring(v))
+			return write(string.format('%.18f', v):gsub('(%..-)0*$', '%1'))
 		end
 	elseif t=='boolean' then
 		if v then
 	expect('1/0', _M.tostring(1/0))
 	expect('-1/0', _M.tostring(-1/0))
 	
+	local value = -0.00223606797749979
+	expect(value, tonumber(_M.tostring(value)))
+	
 	-- a complete file showing key ordering
 	local str = [[
 return {