The Documentation about the floor division in Python says,
The / (division) and // (floor division) operators yield the quotient of their arguments. The numeric arguments are first converted to a common type. Division of integers yields a float, while floor division of integers results in an integer; the result is that of mathematical division with the ‘floor’ function applied to the result.
I'm focusing on the last line, that says,
the result is that of mathematical division with the ‘floor’ function applied to the result
I get a float
in:
>>> 10//2.0
5.0
But an integer
in:
>>> import math
>>> math.floor(10/2.0)
5
So it's clearly not the math.floor
function that Python floor division is using. I want to know what exact procedure is Python following to compute the floor division of two arguments.
Because when taking the floor division of complex
numbers, Python says,
>>> (2+3j)//(4+5j)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't take floor of complex number.
That means Python takes the division and then applies some sort of floor function. What really is it?