note 87819 modified in function.round by danbrown
| From: | danbrown@php.net | Date: | Fri, 26 Dec 2008 17:02:59 +0000 |
| Subject: | note 87819 modified in function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148545@lists.php.net to get a copy of this message | ||
Precision rounding. Works for any value, including negative values, and values between 1 and 0.
<?php
function roundPrecision($value, $precision=3 ){
$round = $precision - floor(log10(abs($value))) - 1;
return round($value, $round);
}
?>
--was--
Precision rounding. Works for any value, including negative values, and values between 1 and 0.
function roundPrecision($value, $precision=3 ){
$round = $precision - floor(log10(abs($value))) - 1;
return round($value, $round);
}
http://php.net/manual/en/function.round.php