note 104859 added to function.round
| From: | hushuilong at gmail dot com | Date: | Tue, 12 Jul 2011 09:16:21 +0000 |
| Subject: | note 104859 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181433@lists.php.net to get a copy of this message | ||
Another way to round half up/down
function round_up ( $value, $precision ) {
$pow = pow ( 10, $precision );
return ceil($value*$pow)/$pow;
}
function round_down ( $value, $precision ) {
$pow = pow ( 10, $precision );
return floor($value*$pow)/$pow;
}
----
Server IP: 222.73.207.145
Probable Submitter: 127.0.0.1 (proxied: 119.145.40.161)
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/104859
Del: integrated -- https://master.php.net/note/delete/104859/integrated
Del: useless -- https://master.php.net/note/delete/104859/useless
Del: bad code -- https://master.php.net/note/delete/104859/bad+code
Del: spam -- https://master.php.net/note/delete/104859/spam
Del: non-english -- https://master.php.net/note/delete/104859/non-english
Del: in docs -- https://master.php.net/note/delete/104859/in+docs
Del: other reasons-- https://master.php.net/note/delete/104859
Reject -- https://master.php.net/note/reject/104859
Search -- https://master.php.net/manage/user-notes.php