Bug #60528 [Com]: EG(precision) affects round function's behavior
| From: | bobwei9 at hotmail dot com | Date: | Thu, 15 Dec 2011 09:55:17 +0000 |
| Subject: | Bug #60528 [Com]: EG(precision) affects round function's behavior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165877@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60528&edit=1
ID: 60528
Comment by: bobwei9 at hotmail dot com
Reported by: laruence@php.net
Summary: EG(precision) affects round function's behavior
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
$ php -dprecision=20 -r 'echo 1.22;'
outputs: 1.2199999999999999734
I think it's only the floating point imprecision and not round()-specific.
Previous Comments:
------------------------------------------------------------------------
[2011-12-15 03:03:28] laruence@php.net
Description:
------------
as doc said:
precision:
The number of significant digits displayed in floating point numbers.
so precision suppose to only affect the display format of a float;
but the fact is:
$php -dprecision=14 -r 'echo round(1.22, 2);'
1.22
php -dprecision=20 -r 'echo round(1.22, 2);'
1.2199999999999999734
the eg(precision) affected the round result.
Test script:
---------------
$php -dprecision=14 -r 'echo round(1.22, 2);'
php -dprecision=20 -r 'echo round(1.22, 2);'
Expected result:
----------------
1.22
1.22
Actual result:
--------------
1.22
1.2199999999999999734
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60528&edit=1