Python's int(x) Rounds Towards Zero
I was surprised to learn that Python's int function rounds floats towards zero.
Here's the relevant excerpt from the official docs:
[…] For floating point numbers, this truncates towards zero.
assert
assert
assert
If you want the floored result, you need to use math.floor. If you want the ceilling result, you need to use math.ceil.