round

PHP 4, PHP 5, PHP 7, PHP 8
round - Rounds a float
Round Online Tool
Manual
Code Examples

Example #1 <span class='function-parameter'>mode</span> examples

Result: Rounding modes with 9.5 float(10) float(9) float(10) float(9) Rounding modes with 8.5 float(9) float(8) float(8) float(9)
PHP Version:

Example #2 <span class='function-parameter'>mode</span> with <span class='function-parameter'>precision</span> examples

Result: Using PHP_ROUND_HALF_UP with 1 decimal digit precision float(1.6) float(-1.6) Using PHP_ROUND_HALF_DOWN with 1 decimal digit precision float(1.5) float(-1.5) Using PHP_ROUND_HALF_EVEN with 1 decimal digit precision float(1.6) float(-1.6) Using PHP_ROUND_HALF_ODD with 1 decimal digit precision float(1.5) float(-1.5)
PHP Version:

Example #3 round examples

Result: float(3) float(4) float(4) float(4) float(5.05) float(5.06) float(300) float(0) float(700) float(1000)
PHP Version:

Example #4 How <span class='function-parameter'>precision</span> affects a float

Result: float(135.79) float(135.79) float(135.8) float(136) float(140) float(100) float(0)
PHP Version:


Example #5 of round

PHP Version:


Function round:

Mathematical Functions Functions

Most used PHP functions