round()
` function to round a floating-point number to its nearest integer. The `round()
` function takes one argument, which is the number to be rounded.<?php
$number = 3.7;
$rounded_number = round($number);
echo "The rounded number is $rounded_number\n";
?>
The rounded number is 4
round()
` function will round it to the nearest even integer. This is known as "banker's rounding". For example :<?php
$number = 2.5;
$rounded_number = round($number);
echo "The rounded number is $rounded_number\n";
?>
The rounded number is 2
ceil()
` or `floor()
` functions, respectively. For example :<?php
$number = 2.5;
$rounded_up = ceil($number);
$rounded_down = floor($number);
echo "The rounded up number is $rounded_up\n";
echo "The rounded down number is $rounded_down\n";
?>​
The rounded up number is 3
The rounded down number is 2