Hacker News new | ask | show | jobs
by musicale 2066 days ago
It's zero in Python, which makes perfect sense to me. Quotient is negative, remainder is zero.
1 comments

Because:

> 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.