Bug #72377 [Opn->Nab]: var_export bad number conversion

From: Date: Fri, 10 Jun 2016 12:45:14 +0000
Subject: Bug #72377 [Opn->Nab]: var_export bad number conversion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201522@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: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: Ubuntu 16.04, Arch Linux PHP Version: 7.0.7 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#201522) next »