Bug #70316 [Csd]: round function bug
| From: | 277460173 at qq dot com | Date: | Fri, 21 Aug 2015 09:20:14 +0000 |
| Subject: | Bug #70316 [Csd]: round function bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195390@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70316&edit=1
ID: 70316
User updated by: 277460173 at qq dot com
Reported by: 277460173 at qq dot com
Summary: round function bug
Status: Closed
Type: Bug
Package: *General Issues
Operating System: linux nginx PHP/5.4.41
PHP Version: 5.4Git-2015-08-21 (Git)
Block user comment: N
Private report: N
New Comment:
ini_set('precision', 14);
Previous Comments:
------------------------------------------------------------------------
[2015-08-21 09:19:36] 277460173 at qq dot com
ini_set('precision', 14);
------------------------------------------------------------------------
[2015-08-21 08:04:15] yohgaki@php.net
s/export()/var_export()/
------------------------------------------------------------------------
[2015-08-21 08:03:11] yohgaki@php.net
This isn't a bug, but a spec that dumps internal data directly.
Anyway, I'm preparing patch that actually rounds float when precision=-1. export() rounds value
to the nearest. What should we do for dump?
------------------------------------------------------------------------
[2015-08-21 07:18:46] laruence@php.net
what's the "dump" function's definition ?
------------------------------------------------------------------------
[2015-08-21 05:32:02] 277460173 at qq dot com
Description:
------------
$source=1370.72;
$local=1238.265;
$aa=($source - $local) / $source;
dump($aa);
$bb= round($aa,4);
dump($bb);
dump(phpversion());
result:
float(0.09663169721022523)
float(0.09660000000000001)
string(6) "5.4.41"
Test script:
---------------
$source=1370.72;
$local=1238.265;
$aa=($source - $local) / $source;
dump($aa);
$bb= round($aa,4);
dump($bb);
dump(phpversion());
Expected result:
----------------
float(0.09663169721022523)
float(0.0966)
string(6) "5.4.41"
Actual result:
--------------
float(0.09663169721022523)
float(0.09660000000000001)
string(6) "5.4.41"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70316&edit=1