Closed lu1210 closed 6 years ago
@lu1210,
As far I can see this is not a cjson issue. In fact, in the lua-cjson library snprintf is used, using 14 digits of precision that can be changed in programming time.
If you do the same with lua:
a = 8.8979 string.format('%3.14f',a) 8.89789962768555
/ > a = 8.8979 / > print(a,require('cjson').encode(a)) 8.8979 8.8978996276855 / > a = tonumber(string.format('%3.1f',a)) / > print(a,require('cjson').encode(a)) 8.9 8.8999996185303 / >
is there a newer cjson lib available?