round up built in function php
echo ceil(0.5); //Prints 1
floor ceil php
echo(floor(0.60) . "<br>"); // 0
echo(floor(0.40) . "<br>"); // 0
echo(floor(5) . "<br>"); // 5
echo(floor(5.1) . "<br>"); //5
echo(floor(-5.1) . "<br>"); // -6
echo(floor(-5.9)); // -6
echo(ceil(0.60) . "<br>"); // 1
echo(ceil(0.40) . "<br>"); // 1
echo(ceil(5) . "<br>"); // 5
echo(ceil(5.1) . "<br>"); // 6
echo(ceil(-5.1) . "<br>"); // -5
echo(ceil(-5.9)); // -5
php round up
//round up to nearest integer
echo(ceil(0.60) . "<br>");
//result 1
php round up
<?php
echo 'Rounding modes with 9.5' . PHP_EOL;
var_dump(round(9.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(9.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_ODD));
echo 'Rounding modes with 8.5' . PHP_EOL;
var_dump(round(8.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(8.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_ODD));
?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us