the function of ceil() in php is not useful in my case, because i want if the number contains from 0.50 to 0.99 then it's will cei开发者_如何学运维l it, if it's smaller than 0.50 it's will not do anything.
example:
6523.70 will be 6524
but
6523.49 will stay same.
i hope you got it guys :)
Thanks
This will only change numbers which are >= .5
function weirdRounding($num) {
if ($num - floor($num) >= .5) {
return ceil($num);
}
return $num;
}
weirdRounding(6523.70) --> 6524
weirdRounding(6523.49) --> 6523.49
Forgive me, I haven't written PHP in a while.
if( ( $var - intval( $var ) ) >= 0.5 )
$var = ceil( $var )
Thus,
6523.70 to 6524 and 6523.49 stays 6523.49
精彩评论