note 94397 modified in function.round by danbrown
| From: | danbrown@php.net | Date: | Mon, 02 Nov 2009 16:56:50 +0000 |
| Subject: | note 94397 modified in function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162340@lists.php.net to get a copy of this message | ||
This functions return ceil($nb) if the double or float value is bigger than "$nb.5" else
it's return floor($nb)
<?php
function arounds_int($nb) {
if(!is_numeric($nb)) {
return false;
}
$sup = round($nb);
$inf = floor($nb);
$try = (double) $inf . '.5' ;
if($nb > $try) {
return $sup;
}
return $inf;
}
?>
--was--
This functions return ceil($nb) if the double or float value is bigger than "$nb.5" else
it's return floor($nb)
function arounds_int($nb) {
if(!is_numeric($nb)) {
return false;
}
$sup = round($nb);
$inf = floor($nb);
$try = (double) $inf . '.5' ;
if($nb > $try) {
return $sup;
}
return $inf;
}
http://php.net/manual/en/function.round.php