]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #41567 (json_encode() double conversion is inconsistent with
authorIlia Alshanetsky <iliaa@php.net>
Mon, 4 Jun 2007 23:52:34 +0000 (23:52 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 4 Jun 2007 23:52:34 +0000 (23:52 +0000)
PHP).

ext/json/json.c

index 53f4bb523cabb735960cbeba3c62f9c6a62d98a9..19f46f2d85826edf3d78cf7f242435c36f1455c1 100644 (file)
@@ -363,7 +363,7 @@ static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC) /* {{{ */
                 double dbl = Z_DVAL_P(val);
 
                 if (!zend_isinf(dbl) && !zend_isnan(dbl)) {
-                    len = spprintf(&d, 0, "%.9g", dbl);
+                   len = spprintf(&d, 0, "%.*g", (int) EG(precision), dbl);
                     if (d) {
                         if (dbl > LONG_MAX && !memchr(d, '.', len)) {
                             smart_str_append_unsigned(buf, (unsigned long)Z_DVAL_P(val));