I see Why is -1/2 evaluated to 0 in C++, but -1 in Python? says integer division rounds towards infinity in Python, namely, floor
is applied to the result.
I thought int(value)
would also do something like floor
, while I get int(-1.5) == -1
in practice, which was expected to be -2
in my mind.
So question is: why rules are inconsistent between integer division
and function int()
? Is there any reasonable explanation?