|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-11-25 14:00 UTC] peehaa@php.net
-Status: Open
+Status: Feedback
[2018-11-25 14:00 UTC] peehaa@php.net
[2018-11-30 15:54 UTC] peehaa@php.net
-Status: Feedback
+Status: No Feedback
[2018-11-30 15:54 UTC] peehaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 00:00:01 2025 UTC |
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>"; }