Bug #71451 [Nab]: var_export() wrong output

From: Date: Mon, 08 Feb 2016 01:40:31 +0000
Subject: Bug #71451 [Nab]: var_export() wrong output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199102@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71451&edit=1 ID: 71451 Updated by: yohgaki@php.net Reported by: nask0 at cod3r dot net Summary: var_export() wrong output Status: Not a bug Type: Bug Package: *General Issues Operating System: Fedora release 23 (Twenty Three) PHP Version: 5.6.17 Block user comment: N Private report: N New Comment: This is not a bug, but there is RFC for this https://wiki.php.net/rfc/precise_float_value JSON numeric defacto standard representation is a concern also. Previous Comments: ------------------------------------------------------------------------ [2016-01-26 13:47:23] rasmus@php.net This is because var_export() is a serialization function and thus uses the serialization_precision setting. Try this: php -d serialize_precision=14 -r 'var_export(1.001); echo "\n" ; var_dump(1.001);' If you set your precision and serialize_precision to the same value you will get the same output from var_dump() and var_export(). var_dump() is not a serialization function since its output can't be read back in by anything. It is just for display purposes. ------------------------------------------------------------------------ [2016-01-26 08:15:17] nask0 at cod3r dot net Description: ------------ var_export(1.001) outputs 1.0009999999999999 instead of 1.001 Test script: --------------- Run in CLI : php -r "var_export(1.001); echo \"\n\"; var_dump(1.001);" Expected result: ---------------- 1.001 double(1.001) Actual result: -------------- 1.0009999999999999 double(1.001) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71451&edit=1

« previous php.bugs (#199102) next »