Logo

Programming-Idioms

History of Idiom 81 > diff from v43 to v44

Edit summary for version 44 by bukzor:
New Python implementation by user [bukzor]

Version 43

2018-01-27, 12:38:50

Version 44

2018-04-08, 06:49:12

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 = int(_x + 0.5)