note 35263 added to function.round
| From: | php-general at lists dot php dot net | Date: | Mon, 25 Aug 2003 21:12:03 +0000 |
| Subject: | note 35263 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55064@lists.php.net to get a copy of this message | ||
Many have thus far mentioned problems encountered when trying to add a small fuzz factor to a number
such as 1.499999999. This is the way I get around that problem using , allbeit probably less
efficient than assuming a small possiblitiy for error:
$numberToRound = 1.5;
//Convert to string.
$numberToRound = "$numberToRound";
//iff number ends in a "5", add fuzz
if (eregi("$5", $pages)) $pages += .000001;
$round = round($pages, 0);
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35263
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35263&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35263&report=yes