Bug #77197 [Opn->Fbk]: rounding problem
| From: | peehaa@php.net | Date: | Sun, 25 Nov 2018 14:00:11 +0000 |
| Subject: | Bug #77197 [Opn->Fbk]: rounding problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218127@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77197&edit=1
ID: 77197
Updated by: peehaa@php.net
Reported by: php_bug at sport-sachsenhausen dot de
Summary: rounding problem
-Status: Open
+Status: Feedback
Type: Bug
Package: *Math Functions
Operating System: Linux
PHP Version: 7.2.12
Block user comment: N
Private report: N
New Comment:
It's not clear what this report is about.
Please provide a clear explanation about what in specific is not working "as expected",
with:
- a simple reproduce case
- the expected result
- the actual result
Previous Comments:
------------------------------------------------------------------------
[2018-11-25 13:00:09] php_bug at sport-sachsenhausen dot de
Description:
------------
rounding function not as expected
Test script:
---------------
# tested PHP 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, 7.2.12
for( $i = 0; $i < 100; $i += 0.001 ) {
$r_0 = round( $i );
$r_up = round( $i, 2, PHP_ROUND_HALF_UP );
$r_down = round( $i, 2, PHP_ROUND_HALF_DOWN );
# a) missing values
# Line 7- 8: 0,085 + 0,095
# Line 73-74: 0,765 - 0,995
# Line 78-79: 1,055 - 4,965
# Line 81-82: 5,005 - 9,795
# Line 83-84: 9,825 - 18,755
# Line 92-93: 18,855 - 38,885
# Line 97-98: 38,945 - 76,225
# Line 101+ : 76,235 - 99,995
if( $r_up == $r_down ) continue; // comment out... -> attention! producing 99.999 lines
# see lines: 1.461 - 4.836, 5.137 - 9.723, 9.905 - 10.000, 10.717 - 18.396,
# 19.215 - 38.703, 39.133 - 76.139, 76.349 - 99.999
echo 'Line ' . $count++ . "| {$i} | round 0: {$r_0} | half up: {$r_up} | half down:
{$r_down} <br>";
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77197&edit=1