note 91800 added to function.round
| From: | microberto at yahoo dot com | Date: | Thu, 25 Jun 2009 20:25:21 +0000 |
| Subject: | note 91800 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157511@lists.php.net to get a copy of this message | ||
Note that the last anonymous one does NOT work for numbers such as (1.444, 2) -- it still returns
1.4
<?php
function roundPrecision($value, $precision=3 ){
// BAD CODE
$round = $precision - floor(log10(abs($value))) - 1;
// DON'T USE ME
return round($value, $round);
}
?>
Instead, Darkstream's works. Use that one.
----
Server IP: 209.41.74.194
Probable Submitter: 173.60.200.24
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/91800
Del: integrated -- https://master.php.net/note/delete/91800/integrated
Del: useless -- https://master.php.net/note/delete/91800/useless
Del: bad code -- https://master.php.net/note/delete/91800/bad+code
Del: spam -- https://master.php.net/note/delete/91800/spam
Del: non-english -- https://master.php.net/note/delete/91800/non-english
Del: in docs -- https://master.php.net/note/delete/91800/in+docs
Del: other reasons-- https://master.php.net/note/delete/91800
Reject -- https://master.php.net/note/reject/91800
Search -- https://master.php.net/manage/user-notes.php