# HG changeset patch # User jbe # Date 1407692889 -7200 # Node ID 2c0db49591be4d17e47decb6d256948c4f72fc59 # Parent 44344b4a52c1d51682c6c7a5ca4096a9a4fff7b0 Increased decimal precision to 17 in json.export(...) diff -r 44344b4a52c1 -r 2c0db49591be libraries/json/json.c --- a/libraries/json/json.c Sun Aug 10 19:41:45 2014 +0200 +++ b/libraries/json/json.c Sun Aug 10 19:48:09 2014 +0200 @@ -1021,7 +1021,7 @@ int pretty; // pretty printing on? (i.e. printing with indentation) luaL_Buffer buf; // Lua buffer containing result string lua_Number num; // number to encode - char numstr[20]; // encoded number (sign, zero, point, 16 significant digits, and terminating NULL byte) + char numstr[21]; // encoded number (sign, zero, point, 17 significant digits, and terminating NULL byte) const char *str; // string to encode size_t strlen; // length of string to encode size_t strpos ; // position in string or position of current key @@ -1094,7 +1094,7 @@ // throw error if number is positive or negative infinity: if (isinf(num)) return luaL_error(L, "JSON export not possible for infinite numbers"); // add Lua's string encoding of the number to the output buffer: - sprintf(numstr, "%.16g", num); + sprintf(numstr, "%.17g", num); luaL_addstring(&buf, numstr); break; // value to encode is of type boolean: