Why doesn't the % operator work the same in Python and Java?
<h3>Python 2.7.1:</h3>

<pre><code>print -34 % 4 # outputs 2
</code></pre>

<h3>Java 1.5.0:</h3>

<pre><code>System.out.println(-34 % 4); // outputs -2
</code></pre>

<p>Which is correct? Why the difference?</p>

<p>The <a href="http://en.wikipedia.org/wiki/Modulo_operator" rel="nofollow">wikipedia article on modulo</a> says </p>

<blockquote>
  <p>When either a or n is negative, this naive definition breaks down and programming languages differ in how these values are defined.</p>
</blockquote>

<p>Maybe this isn't a proper SO question and will get deleted but I'd be interested to see the responses.</p>
