note 87254 added to function.round
| From: | jeff at dealer-choice dot com | Date: | Wed, 26 Nov 2008 20:21:25 +0000 |
| Subject: | note 87254 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146998@lists.php.net to get a copy of this message | ||
darkstream777 at gmx dot net - In evaluating your function I found an instance where your precision
support is not entirely accurate:
function roundDigits( $value, $precision=0 )
{
$precisionFactor = ($precision == 0) ? 1 : pow( 10, $precision );
return round( $value * $precisionFactor ) / $precisionFactor;
}
$b = 99.9947;
echo roundDigits($b,2);
//99.99;
----
Server IP: 208.69.120.35
Probable Submitter: 76.161.243.119
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/87254
Del: integrated -- https://master.php.net/note/delete/87254/integrated
Del: useless -- https://master.php.net/note/delete/87254/useless
Del: bad code -- https://master.php.net/note/delete/87254/bad+code
Del: spam -- https://master.php.net/note/delete/87254/spam
Del: non-english -- https://master.php.net/note/delete/87254/non-english
Del: in docs -- https://master.php.net/note/delete/87254/in+docs
Del: other reasons-- https://master.php.net/note/delete/87254
Reject -- https://master.php.net/note/reject/87254
Search -- https://master.php.net/manage/user-notes.php