Bug #66737 [Com]: 5.5 wrongly rounded to 5
| From: | mail at daniel-berlin dot de | Date: | Tue, 18 Feb 2014 20:30:31 +0000 |
| Subject: | Bug #66737 [Com]: 5.5 wrongly rounded to 5 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184349@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66737&edit=1
ID: 66737
Comment by: mail at daniel-berlin dot de
Reported by: mail at daniel-berlin dot de
Summary: 5.5 wrongly rounded to 5
Status: Open
Type: Bug
Package: Math related
Operating System: Linux
PHP Version: 5.5.9
Block user comment: N
Private report: N
New Comment:
Reproducible with PHP 5.5.4 (cli)
Previous Comments:
------------------------------------------------------------------------
[2014-02-18 20:29:45] mail at daniel-berlin dot de
Description:
------------
5.5 is wrongly rounded to 5 (even with PHP_ROUND_HALF_UP)
Test script:
---------------
<?php
$n = 2.2459431618637;
echo "Expected 5.5 / is " .
round(pow(1024, $n - floor($n)), 2, PHP_ROUND_HALF_UP) . "\n";
echo "Expected 5.5 / is " .
round(pow(1024, $n - floor($n)), 1, PHP_ROUND_HALF_UP) . "\n";
echo "Expected 6 / is " .
round(pow(1024, $n - floor($n)), 0, PHP_ROUND_HALF_UP) . "\n";
echo "Expected 5.50 / is " . number_format(pow(1024, $n - floor($n)), 2) . "\n";
echo "Expected 5.5 / is " . number_format(pow(1024, $n - floor($n)), 1) . "\n";
echo "Expected 6 / is " . number_format(pow(1024, $n - floor($n)), 0) . "\n";
Expected result:
----------------
See output (line 3 and 6 are wrong):
Expected 5.5 / is 5.5
Expected 5.5 / is 5.5
Expected 6 / is 5
Expected 5.50 / is 5.50
Expected 5.5 / is 5.5
Expected 6 / is 5
Actual result:
--------------
See expected result.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66737&edit=1