]> granicus.if.org Git - php/commitdiff
Fixed bug #43053 (Regression: some numbers shown in scientific notation). (int-e...
authorDmitry Stogov <dmitry@php.net>
Mon, 15 Sep 2008 11:47:03 +0000 (11:47 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 15 Sep 2008 11:47:03 +0000 (11:47 +0000)
some 64bit test files may need to be fixed

NEWS
Zend/tests/bug43053.phpt [new file with mode: 0644]
Zend/tests/hex_overflow_32bit.phpt
Zend/tests/zend_strtod.phpt
Zend/zend_strtod.c
ext/standard/tests/general_functions/008.phpt
ext/standard/tests/strings/printf.phpt
main/snprintf.c

diff --git a/NEWS b/NEWS
index 9cc9e81a1343f1fe32c879af7568863d8d583f2b..7850aec94e8a8f58014f63678df776b130c96f68 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -116,6 +116,8 @@ PHP                                                                        NEWS
 - Fixed bug #43666 (Fixed code to use ODBC 3.52 datatypes for 64bit systems). 
   (Patrick)
 - Fixed bug #43540 (rfc1867 handler newlength problem). (Arnaud)
+- Fixed bug #43053 (Regression: some numbers shown in scientific notation).
+  (int-e at gmx dot de)
 - Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines).
   (Nuno)
 - Fixed bug #42604 ("make test" fails with --with-config-file-scan-dir=path).
diff --git a/Zend/tests/bug43053.phpt b/Zend/tests/bug43053.phpt
new file mode 100644 (file)
index 0000000..646aa97
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #43053 (Regression: some numbers shown in scientific notation)
+--FILE--
+<?php
+echo 1200000.00."\n";
+echo 1300000.00."\n";
+echo 1400000.00."\n";
+echo 1500000.00."\n";
+?>
+--EXPECT--
+1200000
+1300000
+1400000
+1500000
index 36e9a7e9d32f3c093c25b0f5fff88a8cf3b9add9..0f192f34978613a18b6e65cb6c70f4104738b5ea 100644 (file)
@@ -22,7 +22,7 @@ foreach ($doubles as $d) {
 echo "Done\n";
 ?>
 --EXPECTF--    
-float(4083360297110%d)
+float(4.0833602971%dE+14)
 float(4.7223664828%dE+21)
 float(1.3521606402%dE+31)
 float(1.9807040628%dE+27)
index 1b11be03882323b114c5898dea33c68483b18d6d..7f4bca596605d50066ae2e867607e6639fbecf8b 100644 (file)
@@ -15,5 +15,5 @@ echo "Done\n";
 float(-100)
 float(808792757210)
 float(-4.5646456464565E+27)
-float(-11276204760067000)
+float(-1.1276204760067E+16)
 Done
index cb5ef58ba16de8d476ba0e64a88cce50bc101b5b..bb93d7b6b12e56089db89cbffcb4ba393af0b50f 100644 (file)
@@ -1720,14 +1720,7 @@ ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sig
                                        if (value(d) > 0.5 + value(eps))
                                                goto bump_up;
                                        else if (value(d) < 0.5 - value(eps)) {
-                                               /* cut ALL traling zeros only if the number of chars is greater than precision 
-                                                * otherwise cut only extra zeros
-                                                */
-                                               if (k < ndigits) {
-                                                       while(*--s == '0' && (s - s0) > k);
-                                               } else {
-                                                       while(*--s == '0');
-                                               }
+                                               while(*--s == '0');
                                                s++;
                                                goto ret1;
                                        }
index bb633c334db9ade5b6749a696d3affc6fd4a0292..f76c73572b4d5501749d10e8c0168e905f1d0e2a 100644 (file)
@@ -34,7 +34,7 @@ array(14) {
   [11]=>
   float(123456789012)
   [12]=>
-  float(1234567890120)
+  float(1.23456789012E+12)
   [13]=>
   float(1.23456789012E+19)
 }
\ No newline at end of file
index 13a8ed0713105299e79b5867262a1c9cf0dcfb05..eb72dbfd6113fdd4be4fe38edb8e61dbbfe19ca6 100755 (executable)
@@ -645,10 +645,10 @@ Array
 -123456
 123456
 -123456
-120000
--120000
-+120000
--120000
+1.2e+5
+-1.2e+5
++1.2e+5
+-1.2e+5
 123456
 -123456
 1.0E+5
@@ -657,10 +657,10 @@ Array
 -123456
 123456
 -123456
-120000
--120000
-+120000
--120000
+1.2E+5
+-1.2E+5
++1.2E+5
+-1.2E+5
 
 *** Output for '%%%.2f' as the format parameter ***
 %12345678900.00
index d42722c79b0dc04ecbec8758ece7198272d99b62..976724126612aa4606ef26efc0933a96eba0fe7a 100644 (file)
@@ -155,10 +155,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
                *dst++ = '-';
        }
 
-       for (i = 0; i < ndigit && digits[i] != '\0'; i++);
-       
-       if ((decpt >= 0 && decpt - i > 4)
-                       || (decpt < 0 && decpt < -3)) {     /* use E-style */
+       if ((decpt >= 0 && decpt > ndigit) || decpt < -3) { /* use E-style */
                /* exponential format (e.g. 1.2345e+13) */
                if (--decpt < 0) {
                        sign = 1;