Modulus operation with negatives values - weird thing?
<p>Can you please tell me how much is <code>(-2) % 5</code>?
According to my Python interpreter is 3, but do you have a wise explanation for this?</p>

<p>I've read that in some languages the result can be machine-dependent, but I'm not sure though.</p>

<p>By the way: most programming languages would disagree with Python and give the result <code>-2</code>. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of <em>a</em> and <em>b</em> is the (strictly positive) rest <em>r</em> of the division of <em>a</em> / <em>b</em>. More precisely, 0 &lt;= <em>r</em> &lt; <em>b</em> by definition.</p>
