title: How do binary operations with XOR in python work?
body: <p>I have the following problem with the xor operator (<code>^</code>) in python. I have two binary numbers, let <code>a = 10100111</code> and <code>b = 10000000</code>. When I use the xor operator, </p>
  
  <pre><code>print (10000000 ^ 10100111) 
  </code></pre>
  
  <p>I get the result of 166671 instead of 00100111. However, when I use </p>
  
  <pre><code>print (100 ^ 101) 
  </code></pre>
  
  <p>I get the appropriate result in binary of 1 (001). Even if I use </p>
  
  <pre><code>print int(a) ^ int(b) 
  </code></pre>
  
  <p>I still get the result of 166671.</p>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li><p>Why do I get the result of 166671 instead of the binary result of 00100111? </p></li>
  <li><p>Why do I get the appropriate result when I use 100^101? </p></li>
  </ol>
  
  <p>I am running Python version 2.7.2. </p>