webmcp

changeset 433:0bbf7717ebfd

Removed exception rule for encoding certain floats
author jbe
date Fri Jan 15 23:27:18 2016 +0100 (2016-01-15)
parents b8477aeb1d9f
children c7a27cfd07d0
files libraries/json/json.c
line diff
     1.1 --- a/libraries/json/json.c	Thu Jan 14 19:09:49 2016 +0100
     1.2 +++ b/libraries/json/json.c	Fri Jan 15 23:27:18 2016 +0100
     1.3 @@ -1123,18 +1123,8 @@
     1.4        if (isinf(num)) return luaL_error(L, "JSON export not possible for infinite numbers");
     1.5        // check if float is integral:
     1.6        if ((double)trunc((double)num) == (double)num) {
     1.7 -        // avoid exponential notation for integers fitting into lua_Integer represented as float:
     1.8 -#if LUA_VERSION_NUM >= 503
     1.9 -        if (num >= LUA_MININTEGER && num <= LUA_MAXINTEGER) {
    1.10 -#else
    1.11 -        if (num >= INT64_MIN && num <= INT64_MAX) {
    1.12 -#endif
    1.13 -          // use decimal notation:
    1.14 -          sprintf(numstr, "%.0f", num);
    1.15 -        } else {
    1.16 -          // use maximum precision:
    1.17 -          sprintf(numstr, "%.17g", num);  // NOTE: e.g. 12345678901234560
    1.18 -        }
    1.19 +        // use maximum precision:
    1.20 +        sprintf(numstr, "%.17g", num);  // NOTE: e.g. 12345678901234560
    1.21        } else {
    1.22          // determine necessary precision to represent double precision floating point number:
    1.23          sprintf(numstr, "%.15g", num);  // NOTE: e.g. 0.009 should not be 0.008999999999999999

Impressum / About Us