Bug #78172 [NEW]: Wrong rounding up/down when decimal places are specified
| From: | vecera at zdenekvecera dot cz | Date: | Sun, 16 Jun 2019 16:18:01 +0000 |
| Subject: | Bug #78172 [NEW]: Wrong rounding up/down when decimal places are specified | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221335@lists.php.net to get a copy of this message | ||
From: vecera at zdenekvecera dot cz
Operating system: Windows, Linux
PHP version: 7.1.30
Package: *Math Functions
Bug Type: Bug
Bug description:Wrong rounding up/down when decimal places are specified
Description:
------------
var_dump(round(1.44444, 3, PHP_ROUND_HALF_DOWN)); // float(1.444) OK
var_dump(round(1.55555, 3, PHP_ROUND_HALF_DOWN)); // float(1.556) BUG
(correct value: 1.555)
var_dump(round(1.77777, 3, PHP_ROUND_HALF_DOWN)); // float(1.778) BUG
(correct value: 1.777)
var_dump(round(1.44444, 3, PHP_ROUND_HALF_UP)); // float(1.444) BUG
(correct value: 1.445)
var_dump(round(1.55555, 3, PHP_ROUND_HALF_UP)); // float(1.556) OK
var_dump(round(1.77777, 3, PHP_ROUND_HALF_UP)); // float(1.778) OK
// PHP version: 7.0.33, 7.1.30, 7.2.19, 7.3.6
--
Edit bug report at https://bugs.php.net/bug.php?id=78172&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78172&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78172&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78172&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78172&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78172&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78172&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78172&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78172&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78172&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78172&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78172&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78172&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78172&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78172&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78172&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78172&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78172&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78172&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78172&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78172&r=mysqlcfg