Logo

Programming-Idioms

History of Idiom 81 > diff from v30 to v31

Edit summary for version 31 by Kevogich:
New Python implementation by user [Kevogich]

Version 30

2016-09-14, 08:32:37

Version 31

2016-09-18, 15:33:07

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).

Imports
import math
Code
y = float(y)
x=int(math.ceil(y))