title: Why do integer div and mod round towards zero?
body: <p>Unlike in C, in Java is the result of <code>x/y</code> and <code>x%y</code> well-defined even for negative operands. Surprisingly, it's defined by rounding towards zero, and not by rounding down (i.e., towards negative infinity). Does anybody have taken any advantage of this definition?</p>
  
  <p><sup>In most cases I just don't care, but sometimes I had to work around this, e.g., when computing an index using modulo <code>array.length</code>.</sup></p>
  
  <p><sup>This is no rant, I'm really interested if there are uses for this definition.</sup></p>