]> granicus.if.org Git - php/commitdiff
Fixed bug #24063 (*printf() did not handle scientific notation correctly)
authorIlia Alshanetsky <iliaa@php.net>
Mon, 30 Jun 2003 01:03:21 +0000 (01:03 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 30 Jun 2003 01:03:21 +0000 (01:03 +0000)
ext/standard/tests/serialize/003.phpt
ext/standard/tests/serialize/bug24063.phpt [new file with mode: 0644]
main/snprintf.c

index 9d5a049540015a42620ed18a4365155bacf5ea85..173f57b72c1c5ebec02d765abdc5cd19adc67dc7 100644 (file)
@@ -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 (file)
index 0000000..3d17299
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #24063 (serialize() missing 0 after the . on scientific notation)
+--INI--
+serialize_precision=100
+precision=12
+--FILE--
+<?php 
+$f = 1.0e-6;
+$s = serialize($f);
+var_dump($s, unserialize($s));
+?>
+--EXPECT--
+string(9) "d:1.0E-6;"
+float(1.0E-6)
index 2e74eb952e825451cb23e16ff72b59c811d4d6a1..71fb78f9d1ec38e34e89c3578796a6bfaa7858d3 100644 (file)
@@ -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;