title: How do you implement XOR using +-*/?
body: <p>How can the XOR operation (on two 32 bit ints) be implemented using only basic arithmetic operations? Do you have to do it bitwise after dividing by each power of 2 in turn, or is there a shortcut? I don't care about execution speed so much as about the simplest, shortest code.</p>
  
  <p><strong>Edit:</strong>
  This is not homework, but a riddle posed on a <a href="http://www.hacker.org" rel="noreferrer">hacker.org</a>. The point is to implement XOR on a stack-based virtual machine with very limited operations (similar to the <a href="http://en.wikipedia.org/wiki/Brainfuck" rel="noreferrer">brainfuck</a> language and yes - no shift or mod). Using that VM is the difficult part, though of course made easier by an algorithm that is short and simple.</p>
  
  <p>While FryGuy's solution is clever, I'll have to go with my original ideal (similar to litb's solution) because comparisons are difficult to use as well in that environment.</p>