Bug #64760 var_export() does not use full precision for floating-point numbers

From: Date: Thu, 24 Oct 2013 00:58:37 +0000
Subject: Bug #64760 var_export() does not use full precision for floating-point numbers
Groups: php.internals 
Request: Send a blank email to internals+get-69823@lists.php.net to get a copy of this message
Hi all, var_export() does not use full precision for floating-point numbers https://bugs.php.net/bug.php?id=64760 var_export() is supposed to export variables to be imported. Therefore, it should use "serialize_precision"(17) rather than "precision"(14). Following simple patch fixes the bug. https://github.com/yohgaki/php-src/commit/987ea9d9b406c75fafbfe0cdc334c81f0739f7dd Since this patch uses full precision like serialize, it will produce different outputs. For instance, ext/standard/tests/general_functions/var_export_basic3.diff 048+ -0.10000000000000001 049+ -0.10000000000000001 050+ string(20) "-0.10000000000000001" 048- -0.1 049- -0.1 050- string(4) "-0.1" 072+ 1.0000000000000001E-5 073+ 1.0000000000000001E-5 074+ string(21) "1.0000000000000001E-5" 072- 1.0E-5 073- 1.0E-5 074- string(6) "1.0E-5" 096+ 1.0000000000000001E-5 097+ 1.0000000000000001E-5 098+ string(21) "1.0000000000000001E-5" 096- 1.0E-5 097- 1.0E-5 098- string(6) "1.0E-5" 108+ 6.0000000000000006E-20 109+ 6.0000000000000006E-20 110+ string(22) "6.0000000000000006E-20" 108- 6.0E-20 109- 6.0E-20 110- string(7) "6.0E-20" 114+ 5.0000000000000001E+42 115+ 5.0000000000000001E+42 116+ string(22) "5.0000000000000001E+42" 114- 5.0E+42 115- 5.0E+42 116- string(7) "5.0E+42" 120+ 3.4000000000000001E-33 121+ 3.4000000000000001E-33 122+ string(22) "3.4000000000000001E-33" 120- 3.4E-33 121- 3.4E-33 122- string(7) "3.4E-33" I suppose it's safe to commit the fix to PHP 5.4 and PHP 5.5 branches. Any comments? -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#69823) next »