note 35263 deleted from function.round by googleguy
| From: | googleguy@php.net | Date: | Sun, 09 Dec 2012 08:26:37 +0000 |
| Subject: | note 35263 deleted from function.round by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192426@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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:
<?php
$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);
?>