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.
If you want the floored result, you need to use math.floor
.