Feb-13-2023, 11:35 PM
The documentation says
So division ( / ) returns a float because that is what it is supposed to do.
The same goes for your floor division question. The documentation says 10 // -3 == floor(10 / -3).
The documentation for floor says this:
10 / -3 = -3.3333.... floor(-3.3333...) = -4
Quote: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.
So division ( / ) returns a float because that is what it is supposed to do.
The same goes for your floor division question. The documentation says 10 // -3 == floor(10 / -3).
The documentation for floor says this:
Quote:math.floor(x)
Return the floor of x, the largest integer less than or equal to x. If x is not a float, delegates to x.__floor__, which should return an Integral value.
10 / -3 = -3.3333.... floor(-3.3333...) = -4