note 79084 added to function.round
| From: | mark at customcartons dot com dot au | Date: | Sat, 10 Nov 2007 05:39:14 +0000 |
| Subject: | note 79084 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132157@lists.php.net to get a copy of this message | ||
[quot]
This can be much more efficient:
<?php
function roundup ($value, $dp)
{
return ceil($value*pow(10, $dp))/pow(10, $dp);
}
function rounddown ($value, $dp)
{
return floor($value*pow(10, $dp))/pow(10, $dp);
}
?>
Much cleaner, isn't it ;)?
[/quot]
Nice cleanup job, you've also managed to solve the issue which "xploded at lycos.com"
noted earlier about passing 0 as the value. Thanks to you both for your input :-)
----
Server IP: 219.94.145.73
Probable Submitter: 125.54.23.229
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/79084
Del: integrated -- https://master.php.net/note/delete/79084/integrated
Del: useless -- https://master.php.net/note/delete/79084/useless
Del: bad code -- https://master.php.net/note/delete/79084/bad+code
Del: spam -- https://master.php.net/note/delete/79084/spam
Del: non-english -- https://master.php.net/note/delete/79084/non-english
Del: in docs -- https://master.php.net/note/delete/79084/in+docs
Del: other reasons-- https://master.php.net/note/delete/79084
Reject -- https://master.php.net/note/reject/79084
Search -- https://master.php.net/manage/user-notes.php