**New course!**Every coder should learn

**Generative AI!**

+ 1

# Python Problem III

I just discovered another something: Why do you think print(-22 // 10) return -3? Can someone explain this code? Thanks for any response that you make.

3 Answers

+ 4

Just like 『 AVD-01 』 said. "//" Is a floor division operator. Which divides the numbers and return the *floor* of the result.
Which is number less than or equal to the answer.
In this case -22/10 = -2.2
And floor(-2.2) = -3
And not -2 as (-2 > -2.2)

+ 2

https://stackoverflow.com/questions/14348219/integer-division-modulo-operation-with-negative-operands-in-JUMP_LINK__&&__python__&&__JUMP_LINK
22 // 10 #2 <= 2.2
-22 // 10 #-3 <= (-2.2)
-22 // 11 #2 <= 2

+ 1

It is called floor division, done using // operator
When floor dividing, the result of normal division is round off to nearest whole number
-22//11 returns -2 as its the nearest whole number, and it never returns -3 I guess