round()


float round ( float $val [, int $precision = 0] )

Description

round() rounds a float

※ available F/W version : all

Parameters

Return values

Returns the rounded value of $val to specified precision (number of digits after the decimal point). The precision can be negative or zero.

Examples

<?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
?>

See also

ceil() / floor()

Remarks

This function is identical to the PHP group’s round() function, but it doesn’t support the third parameter.