Bug #72377 [Nab]: var_export bad number conversion
Edit report at https://bugs.php.net/bug.php?id=72377&edit=1
ID: 72377
User updated by: stefano dot galeazzi at probanet dot it
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:
No thanks (no time to be a master of floats), I just want it working, like it was in PHP 5.
Previous Comments:
------------------------------------------------------------------------
[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)