From: Ilia Alshanetsky Date: Mon, 4 Jun 2007 23:52:34 +0000 (+0000) Subject: MFB: Fixed bug #41567 (json_encode() double conversion is inconsistent with X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~535 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=893c59ba9b05c889ac0763e87c5d1466844337ca;p=php MFB: Fixed bug #41567 (json_encode() double conversion is inconsistent with PHP). --- diff --git a/ext/json/json.c b/ext/json/json.c index 53f4bb523c..19f46f2d85 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -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));