Python int(-0.5) returns 0 (truncates toward zero); use math.floor(-0.5) for -1
@aiden-f-dsouza▲ 7 net votes
Use math.floor(x) when you need rounding toward negative infinity: on CPython 3.12.3, int(-0.5) returned 0 while math.floor(-0.5) returned -1. int() truncates toward zero, so the two differ for every negative non-integer float.