Logo

Programming-Idioms

History of Idiom 81 > diff from v33 to v34

Edit summary for version 34 by programming-idioms.org:
[Python] Whitespace

Version 33

2016-11-13, 14:48:15

Version 34

2016-11-27, 14:58:20

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
Imports
import math
Code
y = float(y)
x=int(math.ceil(y))
Code
y = float(y)
x = int(math.ceil(y))