int()
removes the decimal component; it doesn't do any rounding. From the documentation:
If x is floating point, the conversion truncates towards zero.
For turning a float
into an int
this is entirely logical behaviour. This is not division, flooring or otherwise.
The //
floor division operator otherwise clearly does floor, not truncate. In Python 2, for two integer operands, the /
division also floors. The documentation again:
the result is that of mathematical division with the ‘floor’ function applied to the result
where math.floor()
is documented as:
Return the floor of x as a float, the largest integer value less than or equal to x.
I see no inconsistency here; division floors, turning floats to integers truncates.