round and floor incompatibilities
It turned out to be quite difficult to use round()
and math.floor()
while maintaining compatibility between Python 2 and Python 3. Here are some examples
Python 2
>>> round(0.5) # rounds up, returns float
1.0
>>> math.floor(0.5) # returns float
0.0
Python 3
>>> round(0.5) # rounds to nearest even, returns int
0
>>> math.floor(0.5) # returns int
0