3 ms·
It's zero in Python, which makes perfect sense to me. Quotient is negative, remainder is zero.
by musicale 6y ago
It's zero in Python, which makes perfect sense to me. Quotient is negative, remainder is zero.
- zamadatix 6y agoBecause: > When the variable range is a signed integer, then the expression -range % range is zero. In a programming language with only signed integers, like Java, this expression is always zero. Not because of your intuition on the quotient. E.g. try -8 % 5, -8 % 6, and -8 % 7 and this feeling of perfect sense compared to the languages with unsigned types should melt away.