note 79084 deleted from function.round by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:16:41 +0000 |
| Subject: | note 79084 deleted from function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154782@lists.php.net to get a copy of this message | ||
Note Submitter: mark at customcartons dot com dot au
----
[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 :-)