Bug #66737 [NEW]: 5.5 wrongly rounded to 5
| From: | mail at daniel-berlin dot de | Date: | Tue, 18 Feb 2014 20:29:46 +0000 |
| Subject: | Bug #66737 [NEW]: 5.5 wrongly rounded to 5 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184348@lists.php.net to get a copy of this message | ||
From: mail at daniel-berlin dot de
Operating system: Linux
PHP version: 5.5.9
Package: Math related
Bug Type: Bug
Bug description:5.5 wrongly rounded to 5
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 bug report at https://bugs.php.net/bug.php?id=66737&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66737&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66737&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66737&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66737&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66737&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66737&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66737&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66737&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66737&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66737&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66737&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66737&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66737&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66737&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66737&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66737&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66737&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66737&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66737&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66737&r=mysqlcfg