note 100161 added to function.round

From: Date: Tue, 28 Sep 2010 22:49:46 +0000
Subject: note 100161 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-172790@lists.php.net to get a copy of this message
For lossantis, the results that you describe are not what PHP_HALF_ROUND_UP does. PHP_HALF_ROUND_UP would round 6.3 to 6. In fact, all four $mode values would round 6.3 to 6. The function that you want is ceil -- which rounds everything up. Note that your method has a bug: if you have exactly 6, you change to 6.5, which gets rounded up to 7. The four mode values only control how .5 rounds. Anything less than .5 will round down always. Anything more than .5 (e.g. .5001) rounds up always. If it is exactly .5, then the $mode values matter. Note that if your precision is not the default 0, then this will be 5, .005, or something else rather than .5. PHP_HALF_ROUND_UP is the current behavior (versions prior to 5.3). The new behavior is that you can choose to round differently in 5.3 (and presumably higher). ---- Server IP: 69.147.83.197 Probable Submitter: 71.182.227.191 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/100161 Del: integrated -- https://master.php.net/note/delete/100161/integrated Del: useless -- https://master.php.net/note/delete/100161/useless Del: bad code -- https://master.php.net/note/delete/100161/bad+code Del: spam -- https://master.php.net/note/delete/100161/spam Del: non-english -- https://master.php.net/note/delete/100161/non-english Del: in docs -- https://master.php.net/note/delete/100161/in+docs Del: other reasons-- https://master.php.net/note/delete/100161 Reject -- https://master.php.net/note/reject/100161 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172790) next »