note 86330 added to function.round
| From: | darkstream777 at gmx dot net | Date: | Mon, 13 Oct 2008 15:16:34 +0000 |
| Subject: | note 86330 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145321@lists.php.net to get a copy of this message | ||
Here is another method to round digits with precision support:
function roundDigits( $value, $precision=0 )
{
$precisionFactor = ($precision == 0) ? 1 : pow( 10, $precision );
return round( $value * $precisionFactor ) / $precisionFactor;
}
Example:
echo roundDigits(1.859438,2) . "<br />"; // equals 1.86
echo roundDigits(1.444444,4); // equals 1.4444
Greetings, darki
----
Server IP: 69.147.83.197
Probable Submitter: 84.146.154.35
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/86330
Del: integrated -- https://master.php.net/note/delete/86330/integrated
Del: useless -- https://master.php.net/note/delete/86330/useless
Del: bad code -- https://master.php.net/note/delete/86330/bad+code
Del: spam -- https://master.php.net/note/delete/86330/spam
Del: non-english -- https://master.php.net/note/delete/86330/non-english
Del: in docs -- https://master.php.net/note/delete/86330/in+docs
Del: other reasons-- https://master.php.net/note/delete/86330
Reject -- https://master.php.net/note/reject/86330
Search -- https://master.php.net/manage/user-notes.php