php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60528 EG(precision) affects round function's behavior
Submitted: 2011-12-15 03:03 UTC Modified: 2011-12-15 10:11 UTC
From: laruence@php.net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.8 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: laruence@php.net
New email:
PHP Version: OS:

 

 [2011-12-15 03:03 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-15 09:55 UTC] bobwei9 at hotmail dot com
$ php -dprecision=20 -r 'echo 1.22;'

outputs: 1.2199999999999999734


I think it's only the floating point imprecision and not round()-specific.
 [2011-12-15 10:11 UTC] laruence@php.net
hmm, seems you are right,  I should close this.
 [2011-12-15 10:11 UTC] laruence@php.net
-Status: Open +Status: Bogus
 [2011-12-15 10:11 UTC] laruence@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC