Answer the question
In order to leave comments, you need to log in
How to understand the principle of working with minuses in Python?
I am watching a lecture by Timofey Khiryanov. And I do not understand the logic of this part of his lectures:
(-12) // 5 = -3
(-12) % 5 = 3
(-11) // 10 = -2
(-11) % 10 = 9
Answer the question
In order to leave comments, you need to log in
https://ru.wikipedia.org/wiki/Division_with_remainder
Remainder sign The remainder
operation in programming languages can return a negative result (for a negative dividend or divisor). There are two options:
The sign of the remainder is the same as the sign of the dividend: the incomplete quotient rounds towards zero.
The sign of the remainder is the same as the sign of the divisor: the partial quotient rounds to -∞.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question