title: Best way to make Java's modulus behave like it should with negative numbers?
body: <p>In java when you do</p>
  
  <pre><code>a % b
  </code></pre>
  
  <p>If a is negative, it will return a negative result, instead of wrapping around to b like it should. What's the best way to fix this? Only way I can think is</p>
  
  <pre><code>a &lt; 0 ? b + a : a % b
  </code></pre>