Bug #66179 [Asn->Csd]: var_export() exports float as integer

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=66179&edit=1

 ID:                 66179
 Updated by:         [email protected]
 Reported by:        david at grudl dot com
 Summary:            var_export() exports float as integer
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Variables related
 PHP Version:        5.5.6
 Assigned To:        ajf
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8d217db369d83de22db6c2e6ad9a440d6c59518f
Log: Fix bug #66179


Previous Comments:
------------------------------------------------------------------------
[2015-06-29 18:57:03] xuefer at gmail dot com

Not sure if this is the same problem

http://3v4l.org/ZRPXO

var_export(5.3); echo "\n";
var_dump(5.3); echo "\n";

outputs:
5.29999999999999982236432
float(5.3)

in this case luckily 5.29999999999999982236432 == 5.3, and it pass ($a === eval('return ' . var_export($a, true) . ';')) definition
but i give this example to show that var_dump is better (looking) than var_export on double value

so please take it seriously

------------------------------------------------------------------------
[2014-07-03 16:48:04] [email protected]

($a === eval('return ' . var_export($a, true) . ';')) should result in true for any given $a. "1" isn't a correct representation of float(1) as it results in int(1).

------------------------------------------------------------------------
[2013-11-29 22:30:09] [email protected]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

A float(1.0) is stored as a float(1) (it's the same), so var_export(1.0) outputs 1.

------------------------------------------------------------------------
[2013-11-27 09:41:30] utkarsh dot parekh at yahoo dot in

If you try this var_export(2.1245) returns "2.1245". It is right.

------------------------------------------------------------------------
[2013-11-26 15:56:35] david at grudl dot com

Description:
------------
var_export(1.0) returns "1" instead of "1.0" in all PHP versions 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66179&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.