title: Java: confirm method Binary division and find remainder is correct?
body: <p>I am parsing binary files and have to implement a CRC algorithm to ensure the file is not corrupted. Problem is that I can't seem to get the binary math working when using larger numbers. </p>
  
  <p>The example I'm trying to get working:</p>
  
  <p><code>BigInteger G = new BigInteger("11001", 2);<br>
  BigInteger M = new BigInteger("1110010000", 2);<br>
  BigInteger R = M.remainder(G);</code></p>
  
  <p>I am expecting:<br>
  <code>R = "0101"</code></p>
  
  <p>But I am getting:<br>
  <code>R = "1100"</code></p>
  
  <p>I am assuming the remainder of 0101 is correct since it is given to me in this book I am using as a reference for the CRC algorithm (it's not based in Java), but I can't seem to get it working. I can get small binary calculations to work that I have solved by hand, but not the larger ones. I'll admit that I haven't worked the larger ones by hand yet, that is my next step, but I wanted to see if someone could point out a glaring flaw I have in my code. </p>
  
  <p>Can anyone confirm or deny that my methodology is correct?</p>
  
  <p>Thanks</p>