Answers for "round if 20 to 15 php"

PHP
1

php float precision

<?php
var_dump(round(3.4)); // =>3
var_dump(round(3.5)); // =>4
var_dump(round(3.6)); // =>4
var_dump(round(3.6, 0)); // =>4
var_dump(round(5.045, 2)); // =>5.05
var_dump(round(5.055, 2)); // =>5.06
var_dump(round(345, -2)); // =>300
var_dump(round(345, -3)); // =>0
var_dump(round(678, -2)); // =>700
var_dump(round(678, -3));  // =>1000
?>
Posted by: Guest on December-03-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