float round ( float $val [, int $precision = 0] )
round() rounds a float
※ available F/W version : all
Returns the rounded value of $val to specified precision (number of digits after the decimal point). The precision can be negative or zero.
<?php
$val = 123.141592;
$ret = round($val, 2);
echo "ret = $ret\r\n"; // OUTPUT: ret = 123.14
$ret = round($val);
echo "ret = $ret\r\n"; // OUTPUT: ret = 123
$ret = round($val, 4);
echo "ret = $ret\r\n"; // OUTPUT: ret = 123.1416
$ret = round($val, -2);
echo "ret = $ret\r\n"; // OUTPUT: ret = 100
?>
This function is identical to the PHP group’s round() function, but it doesn’t support the third parameter.