webmcp

changeset 192:33c8f7029cfa

Minimum decimal floating point precision of 16 in json.encode(...)
author jbe
date Sun Aug 10 20:18:57 2014 +0200 (2014-08-10)
parents e61bf25f3d04
children 0014a7c22013
files libraries/json/json.c
line diff
     1.1 --- a/libraries/json/json.c	Sun Aug 10 20:04:36 2014 +0200
     1.2 +++ b/libraries/json/json.c	Sun Aug 10 20:18:57 2014 +0200
     1.3 @@ -1094,9 +1094,7 @@
     1.4        // throw error if number is positive or negative infinity:
     1.5        if (isinf(num)) return luaL_error(L, "JSON export not possible for infinite numbers");
     1.6        // determine necessary precision to represent double precision floating point number:
     1.7 -      sprintf(numstr, "%.14g", num);
     1.8 -      if (strtod(numstr, NULL) != num) sprintf(numstr, "%.15g", num);
     1.9 -      if (strtod(numstr, NULL) != num) sprintf(numstr, "%.16g", num);
    1.10 +      sprintf(numstr, "%.16g", num);
    1.11        if (strtod(numstr, NULL) != num) sprintf(numstr, "%.17g", num);
    1.12        // add string encoding of the number to the output buffer:
    1.13        luaL_addstring(&buf, numstr);

Impressum / About Us