What is the rule behind minus (-) number devide by (//) integer division

34 Views Asked by At

In Python, the principle behind integer division, which is denoted by two forward slashes //, is to divide one integer by another, and rather than giving the exact answer, it rounds down the answer to an integer. I can understand that part.

print(8//5)
# output : 1

But why does the output differ when the first number is negative?

print(-8//5)
# output : -2
0

There are 0 best solutions below