title: modulus operand in ruby compared to php
body: <p>I'm looking for a simple explanation for how Ruby's modulo operand works and why, in Ruby</p>
  
  <pre><code>puts  4 % 3   # 1
  puts -4 % 3   # 2 &lt;--why?
  puts -4 % -3  # -1 
  </code></pre>
  
  <p>but in PHP:</p>
  
  <pre><code>&lt;?php
  
  echo  4 % 3;  #  1
  echo -4 % 3;  # -1
  echo -4 % -3; # -1
  </code></pre>
  
  <p>Looks to me like -4 % 3 is actally 8 % 3 (8 being the difference between 4 and -4).</p>