Bug #72377 [Nab]: var_export bad number conversion

From: Date: Fri, 10 Jun 2016 13:54:53 +0000
Subject: Bug #72377 [Nab]: var_export bad number conversion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201527@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72377&edit=1

 ID:                 72377
 Updated by:         cmb@php.net
 Reported by:        stefano dot galeazzi at probanet dot it
 Summary:            var_export bad number conversion
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   Ubuntu 16.04, Arch Linux
 PHP Version:        7.0.7
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

For the record: the behavior has changed as of PHP 5.4.22 and
5.5.6, respectively, as result of fixing bug #64760.


Previous Comments:
------------------------------------------------------------------------
[2016-06-10 13:46:20] stefano dot galeazzi at probanet dot it

Thanks a lot!!! ^_^

------------------------------------------------------------------------
[2016-06-10 13:42:03] nikic@php.net

Change the serialize_precision setting to a lower value to restore the previous behavior. Note that
this will also affect the output of serialize() and that the values exported in this way may not
coincide with the original values.

------------------------------------------------------------------------
[2016-06-10 13:33:22] stefano dot galeazzi at probanet dot it

No thanks (no time to be a master of floats), I just want it working, like it was in PHP 5.

------------------------------------------------------------------------
[2016-06-10 12:45:12] cmb@php.net

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/

Thank you for your interest in PHP.



------------------------------------------------------------------------
[2016-06-10 12:31:39] stefano dot galeazzi at probanet dot it

Description:
------------
var_export() makes unnecessary and wrong number conversions.

Test script:
---------------
php --version
PHP 7.0.7 (cli) (built: May 25 2016 18:40:26) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

php -r 'echo(var_export(0.98) . "\n");'
0.97999999999999998


Expected result:
----------------
php -r 'echo(var_export(0.98) . "\n");'
0.98


Actual result:
--------------
php -r 'echo(var_export(0.98) . "\n");'
0.97999999999999998



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



--
Edit this bug report at https://bugs.php.net/bug.php?id=72377&edit=1


Thread (6 messages)

« previous php.bugs (#201527) next »