From: Ilia Alshanetsky Date: Mon, 30 Jun 2003 01:03:21 +0000 (+0000) Subject: Fixed bug #24063 (*printf() did not handle scientific notation correctly) X-Git-Tag: BEFORE_ARG_INFO~545 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cb5c9c6bad0c79cb8b936c5017ca799ae50cd6c;p=php Fixed bug #24063 (*printf() did not handle scientific notation correctly) --- diff --git a/ext/standard/tests/serialize/003.phpt b/ext/standard/tests/serialize/003.phpt index 9d5a049540..173f57b72c 100644 --- a/ext/standard/tests/serialize/003.phpt +++ b/ext/standard/tests/serialize/003.phpt @@ -22,4 +22,4 @@ d:8\.52[89][0-9]+E-22; float\(8\.529E-22\) d:9\.[0-9]*E-9; -float\(9\.E-9\) +float\(9\.0E-9\) diff --git a/ext/standard/tests/serialize/bug24063.phpt b/ext/standard/tests/serialize/bug24063.phpt new file mode 100644 index 0000000000..3d172993eb --- /dev/null +++ b/ext/standard/tests/serialize/bug24063.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #24063 (serialize() missing 0 after the . on scientific notation) +--INI-- +serialize_precision=100 +precision=12 +--FILE-- + +--EXPECT-- +string(9) "d:1.0E-6;" +float(1.0E-6) diff --git a/main/snprintf.c b/main/snprintf.c index 2e74eb952e..71fb78f9d1 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -404,6 +404,9 @@ ap_php_gcvt(double number, int ndigit, char *buf, boolean_e altform) *p2++ = '.'; for (i = 1; i < ndigit; i++) *p2++ = *p1++; + if (*(p2 - 1) == '.') { + *p2++ = '0'; + } *p2++ = 'e'; if (decpt < 0) { decpt = -decpt;