Bug #66188 [Opn->Nab]: var_export exports double wrong

From: Date: Fri, 29 Nov 2013 09:18:43 +0000
Subject: Bug #66188 [Opn->Nab]: var_export exports double wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183003@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66188&edit=1 ID: 66188 Updated by: nikic@php.net Reported by: chudinov at yahoo dot com Summary: var_export exports double wrong -Status: Open +Status: Not a bug Type: Bug Package: Variables related Operating System: Windows PHP Version: 5.4.22 Block user comment: N Private report: N New Comment: var_export since recently uses the (typically larger) serialize_precision ini setting, rather than the precision one used for normal output. Previous Comments: ------------------------------------------------------------------------ [2013-11-29 00:23:09] phpmpan at mpan dot pl Both outputs are equally valid according to how floating-point numbers are used. 1.1 is equivalent of 1.1000000000000001 and it doesn't matter which one you use. None of the outputs is valid if you want to convey actual, unchanged value, as the actual value of 1.1(dec) is infinite sequence 1.0(0011)(bin) which, stored in a 64-bit IEEE-754 value, is equal to decimal 1.100000000000000088817841970012523233890533447265625. Hence either this is NaB or the bug is that var_export doesn't use full precision available. ------------------------------------------------------------------------ [2013-11-28 00:02:59] chudinov at yahoo dot com Description: ------------ var_export exports double numbers with wrong precision and as wrong number. For example 1.1 will be exported as 1.1000000000000001 This bug is introduced in 5.4.22 Test script: --------------- echo var_export(1.1, true); Expected result: ---------------- echo var_export(1.1, true); 1.1 Actual result: -------------- 1.1000000000000001 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66188&edit=1

« previous php.bugs (#183003) next »