]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #36392 (wrong number of decimal digits with %e specifier in
authorIlia Alshanetsky <iliaa@php.net>
Fri, 22 Dec 2006 15:30:18 +0000 (15:30 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 22 Dec 2006 15:30:18 +0000 (15:30 +0000)
sprintf).

ext/standard/formatted_print.c
ext/standard/tests/strings/bug36392.phpt [new file with mode: 0644]

index b031bc8513c050d27df5a1f4931a9ad9ba8d0307..11ea8454e1b3e7246579ac2ff818870116041d54 100644 (file)
@@ -368,9 +368,6 @@ php_sprintf_appenddouble(char **buffer, int *pos,
 
        switch (fmt) {          
                case 'e':
-                       if (precision) {
-                               precision--;
-                       }
                case 'E':
                case 'f':
                case 'F':
diff --git a/ext/standard/tests/strings/bug36392.phpt b/ext/standard/tests/strings/bug36392.phpt
new file mode 100644 (file)
index 0000000..8e4cd16
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #36392 (wrong number of decimal digits with %e specifier in sprintf)
+--FILE--
+<?php
+       echo sprintf("%e\n", 1.123456789);
+       echo sprintf("%.10e\n", 1.123456789);
+       echo sprintf("%.0e\n", 1.123456789);
+       echo sprintf("%.1e\n", 1.123456789);
+       echo sprintf("%5.1e\n", 1.123456789);
+?>
+--EXPECT--
+1.123457e+0
+1.1234567890e+0
+1e+0
+1.1e+0
+1.1e+0