com php-src: Fixed Bug 64760 var_export() does not use full precision for floating-point numbers: ex
t/standard/tests/general_functions/var_export-locale.phpt ext/standard/tests/general_functions/var_export_basic 3.phpt
ext/standard/tests/general_functions/var_expor t_basic5.phpt ext/standard/var.c tests/lang/bug2 4640.phpt
| From: | Yasuo Ohgaki | Date: | Tue, 29 Oct 2013 08:24:23 +0000 |
| Subject: | com php-src: Fixed Bug 64760 var_export() does not use full precision for floating-point numbers: ex t/standard/tests/general_functions/var_export-locale.phpt ext/standard/tests/general_functions/var_export_basic 3.phpt ext/standard/tests/general_functions/var_expor t_basic5.phpt ext/standard/var.c tests/lang/bug2 4640.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73823@lists.php.net to get a copy of this message | ||
Commit: 4dc4302a30e225bcbf468b7ce01a4c5929f87a07
Author: Yasuo Ohgaki <yohgaki@php.net> Tue, 29 Oct 2013 17:24:23 +0900
Parents: 69808d698c0646ab6cddec45c7362f4aa60fac06
Branches: PHP-5.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4dc4302a30e225bcbf468b7ce01a4c5929f87a07
Log:
Fixed Bug 64760 var_export() does not use full precision for floating-point numbers
Bugs:
https://bugs.php.net/64760
Changed paths:
M ext/standard/tests/general_functions/var_export-locale.phpt
M ext/standard/tests/general_functions/var_export_basic3.phpt
M ext/standard/tests/general_functions/var_export_basic5..phpt
M ext/standard/var.c
M tests/lang/bug24640.phpt
Diff:
diff --git a/ext/standard/tests/general_functions/var_export-locale.phpt
b/ext/standard/tests/general_functions/var_export-locale.phpt
index 37142cf..3cbebe9 100644
--- a/ext/standard/tests/general_functions/var_export-locale.phpt
+++ b/ext/standard/tests/general_functions/var_export-locale.phpt
@@ -784,15 +784,15 @@ string(20) "array (
Iteration 13
array (
0 => 10.5,
- 1 => 5.6,
+ 1 => 5.5999999999999996,
)
array (
0 => 10.5,
- 1 => 5.6,
+ 1 => 5.5999999999999996,
)
-string(34) "array (
+string(49) "array (
0 => 10.5,
- 1 => 5.6,
+ 1 => 5.5999999999999996,
)"
diff --git a/ext/standard/tests/general_functions/var_export_basic3.phpt
b/ext/standard/tests/general_functions/var_export_basic3.phpt
index 2997215..9e27d90 100644
--- a/ext/standard/tests/general_functions/var_export_basic3.phpt
+++ b/ext/standard/tests/general_functions/var_export_basic3.phpt
@@ -96,9 +96,9 @@ string(1) "0"
-- Iteration: -0.1 --
--0.1
--0.1
-string(4) "-0.1"
+-0.10000000000000001
+-0.10000000000000001
+string(20) "-0.10000000000000001"
-- Iteration: 10.0000000000000000005 --
@@ -120,9 +120,9 @@ string(6) "100000"
-- Iteration: 1e-5 --
-1.0E-5
-1.0E-5
-string(6) "1.0E-5"
+1.0000000000000001E-5
+1.0000000000000001E-5
+string(21) "1.0000000000000001E-5"
-- Iteration: 1e+5 --
@@ -144,9 +144,9 @@ string(6) "100000"
-- Iteration: 1E-5 --
-1.0E-5
-1.0E-5
-string(6) "1.0E-5"
+1.0000000000000001E-5
+1.0000000000000001E-5
+string(21) "1.0000000000000001E-5"
-- Iteration: .5e+7 --
@@ -156,20 +156,20 @@ string(7) "5000000"
-- Iteration: .6e-19 --
-6.0E-20
-6.0E-20
-string(7) "6.0E-20"
+6.0000000000000006E-20
+6.0000000000000006E-20
+string(22) "6.0000000000000006E-20"
-- Iteration: .05E+44 --
-5.0E+42
-5.0E+42
-string(7) "5.0E+42"
+5.0000000000000001E+42
+5.0000000000000001E+42
+string(22) "5.0000000000000001E+42"
-- Iteration: .0034E-30 --
-3.4E-33
-3.4E-33
-string(7) "3.4E-33"
+3.4000000000000001E-33
+3.4000000000000001E-33
+string(22) "3.4000000000000001E-33"
===DONE===
diff --git a/ext/standard/tests/general_functions/var_export_basic5.phpt
b/ext/standard/tests/general_functions/var_export_basic5.phpt
index 96b3f54..1512fa8 100644
--- a/ext/standard/tests/general_functions/var_export_basic5.phpt
+++ b/ext/standard/tests/general_functions/var_export_basic5.phpt
@@ -233,15 +233,15 @@ string(20) "array (
--Iteration: array(10.5, 5.6) --
array (
0 => 10.5,
- 1 => 5..6,
+ 1 => 5.5999999999999996,
)
array (
0 => 10.5,
- 1 => 5.6,
+ 1 => 5.5999999999999996,
)
-string(34) "array (
+string(49) "array (
0 => 10.5,
- 1 => 5.6,
+ 1 => 5.5999999999999996,
)"
@@ -274,4 +274,4 @@ string(41) "array (
1 => 'test',
)"
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/standard/var.c b/ext/standard/var.c
index f71c4a4..2d0339a 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -436,7 +436,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
smart_str_append_long(buf, Z_LVAL_PP(struc));
break;
case IS_DOUBLE:
- tmp_len = spprintf(&tmp_str, 0,"%.*H", (int) EG(precision), Z_DVAL_PP(struc));
+ tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_PP(struc));
smart_str_appendl(buf, tmp_str, tmp_len);
efree(tmp_str);
break;
diff --git a/tests/lang/bug24640.phpt b/tests/lang/bug24640.phpt
index 919b38e..e41d020 100644
--- a/tests/lang/bug24640.phpt
+++ b/tests/lang/bug24640.phpt
@@ -36,22 +36,22 @@ test(1.7e-1000);
===DONE===
<?php exit(0); ?>
--EXPECTF--
-1.7E+300
+1.7000000000000001E+300
float(1.7E+300)
1.7E+300
1.7E+300
------
-1.7E-300
+1.7000000000000001E-300
float(1.7E-300)
1.7E-300
1.7E-300
------
-1.7E+79
+1.7000000000000002E+79
float(1.7E+79)
1.7E+79
1.7E+79
------
-1.7E-79
+1.6999999999999999E-79
float(1.7E-79)
1.7E-79
1.7E-79
@@ -71,7 +71,7 @@ float(1.7E+81)
1.7E+81
1.7E+81
------
-1.7E-81
+1.6999999999999999E-81
float(1.7E-81)
1.7E-81
1.7E-81
@@ -81,7 +81,7 @@ float(I%s)
I%s
I%s
------
-1.69998107421E-319
+1.6999810742105611E-319
float(1.69998107421E-319)
1.69998107421E-319
1.69998107421E-319
@@ -91,7 +91,7 @@ float(I%s)
I%s
I%s
------
-1.70007988734E-320
+1.7000798873397294E-320
float(1.70007988734E-320)
1.70007988734E-320
1.70007988734E-320
@@ -101,7 +101,7 @@ float(I%s)
I%s
I%s
------
-1.69958582169E-321
+1.6995858216938881E-321
float(1.69958582169E-321)
1.69958582169E-321
1.69958582169E-321