Answer the question
In order to leave comments, you need to log in
How to round a number only up?
There is an array of numbers, for example: 21749, 21751, you need to get 21750, 21800 i.e. round only up.
echo round(21749, -1); // 21750
echo round(21751, -2); // 21800
$numbers = array(21749, 21751,);
foreach ($numbers as $number) {
$precision = -1;
do{
$r = round($number, $precision);
$precision += (-1);
} while($r < $number);
echo ':' . $r . '<br/>';
}
Answer the question
In order to leave comments, you need to log in
function up(num) {
return Math.ceil(num/50)*50
}
up(21749); //21750
up(21750); //21750
up(21751); //21800
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question