Home > PHP > Function > Math > round()

round()

round - Rounds a float

Syntax

float round (float $val, int $precision, int $mode)

Arguments

  • val - The value to round
  • precision - The optional number of decimal digits to round to.
  • mode - One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, or PHP_ROUND_HALF_ODD.

Description

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

Version

PHP 4, 5

Return value

The rounded value