Bug #74109 [Opn->Nab]: round() PHP_ROUND_HALF_DOWN mode is broken

From: Date: Thu, 16 Feb 2017 15:42:17 +0000
Subject: Bug #74109 [Opn->Nab]: round() PHP_ROUND_HALF_DOWN mode is broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207414@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74109&edit=1 ID: 74109 Updated by: requinix@php.net Reported by: pandenitz at mail dot ru Summary: round() PHP_ROUND_HALF_DOWN mode is broken -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: Win 7 64 PHP Version: 7.0.16 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://php.net/manual/en/function.round.php > Round val down to precision decimal places towards zero, when it is half way > there. Making 1.5 into 1 and -1.5 into -1. 6 is not half way. Previous Comments: ------------------------------------------------------------------------ [2017-02-16 13:52:23] pandenitz at mail dot ru Description: ------------ PHP_ROUND_HALF_DOWN mode for round() doesn't work, it still increments last allowed decimal digit if next is larger than 4 Test script: --------------- var_dump(100 / 6); var_dump(round(100 / 6, 4, PHP_ROUND_HALF_UP)); var_dump(round(100 / 6, 4, PHP_ROUND_HALF_DOWN)); Expected result: ---------------- float 16.666666666667 float 16.6667 float 16.6666 Actual result: -------------- float 16.666666666667 float 16.6667 float 16.6667 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74109&edit=1

« previous php.bugs (#207414) next »