Answers for "php ceil floor"

PHP
0

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
Posted by: Guest on January-02-2021
3

php round up

//round up to nearest integer
echo(ceil(0.60) . "<br>");
//result 1
Posted by: Guest on June-09-2020
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));
?>
Posted by: Guest on June-11-2020

Browse Popular Code Answers by Language