Skip to content

Commit 1474d9d

Browse files
committed
Fixed bug #43053 (Regression: some numbers shown in scientific notation). (int-e at gmx dot de)
some 64bit test files may need to be fixed
1 parent 612c93b commit 1474d9d

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

Zend/tests/bug43053.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #43053 (Regression: some numbers shown in scientific notation)
3+
--FILE--
4+
<?php
5+
echo 1200000.00."\n";
6+
echo 1300000.00."\n";
7+
echo 1400000.00."\n";
8+
echo 1500000.00."\n";
9+
?>
10+
--EXPECT--
11+
1200000
12+
1300000
13+
1400000
14+
1500000

Zend/tests/hex_overflow_32bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ foreach ($doubles as $d) {
2222
echo "Done\n";
2323
?>
2424
--EXPECTF--
25-
float(4083360297110%d)
25+
float(4.0833602971%dE+14)
2626
float(4.7223664828%dE+21)
2727
float(1.3521606402%dE+31)
2828
float(1.9807040628%dE+27)

Zend/tests/zend_strtod.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ echo "Done\n";
1515
float(-100)
1616
float(808792757210)
1717
float(-4.5646456464565E+27)
18-
float(-11276204760067000)
18+
float(-1.1276204760067E+16)
1919
Done

Zend/zend_strtod.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,14 +1720,7 @@ ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sig
17201720
if (value(d) > 0.5 + value(eps))
17211721
goto bump_up;
17221722
else if (value(d) < 0.5 - value(eps)) {
1723-
/* cut ALL traling zeros only if the number of chars is greater than precision
1724-
* otherwise cut only extra zeros
1725-
*/
1726-
if (k < ndigits) {
1727-
while(*--s == '0' && (s - s0) > k);
1728-
} else {
1729-
while(*--s == '0');
1730-
}
1723+
while(*--s == '0');
17311724
s++;
17321725
goto ret1;
17331726
}

ext/standard/tests/general_functions/008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ array(14) {
3434
[11]=>
3535
float(123456789012)
3636
[12]=>
37-
float(1234567890120)
37+
float(1.23456789012E+12)
3838
[13]=>
3939
float(1.23456789012E+19)
4040
}

ext/standard/tests/strings/printf.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,10 @@ Array
645645
-123456
646646
123456
647647
-123456
648-
120000
649-
-120000
650-
+120000
651-
-120000
648+
1.2e+5
649+
-1.2e+5
650+
+1.2e+5
651+
-1.2e+5
652652
123456
653653
-123456
654654
1.0E+5
@@ -657,10 +657,10 @@ Array
657657
-123456
658658
123456
659659
-123456
660-
120000
661-
-120000
662-
+120000
663-
-120000
660+
1.2E+5
661+
-1.2E+5
662+
+1.2E+5
663+
-1.2E+5
664664

665665
*** Output for '%%%.2f' as the format parameter ***
666666
%12345678900.00

main/snprintf.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
155155
*dst++ = '-';
156156
}
157157

158-
for (i = 0; i < ndigit && digits[i] != '\0'; i++);
159-
160-
if ((decpt >= 0 && decpt - i > 4)
161-
|| (decpt < 0 && decpt < -3)) { /* use E-style */
158+
if ((decpt >= 0 && decpt > ndigit) || decpt < -3) { /* use E-style */
162159
/* exponential format (e.g. 1.2345e+13) */
163160
if (--decpt < 0) {
164161
sign = 1;

0 commit comments

Comments
 (0)