Logo

Programming-Idioms

History of Idiom 81 > diff from v25 to v26

Edit summary for version 26 by :
New PHP implementation by user [AgillaDev]

Version 25

2016-02-18, 18:22:38

Version 26

2016-03-04, 13:46:57

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Code
$y = round($x);
Doc URL
http://php.net/manual/en/function.round.php