title: How do I represent an integer in binary so I can compare using XOR?
body: <p>I have to create a code that takes 1-6 bits of binary, stuffs the most significant bits with 0 if the string isn't 6 already and compare 2 packets of 3 bits using the XOR operation. The outputs are weird, I think its because I'm comparing the integer 0, and not the binary number 0 when doing the XOR and it's messing up.</p>
  
  <pre><code>char binary[300];
  
  cin &gt;&gt; binary;
  
  int size = strlen(binary);
  //cout &lt;&lt; "Size: " &lt;&lt; size &lt;&lt; endl;
  
  int a,b,c,d,e,f;
  
  if(size == 1){
      a = 0;
      b = 0;
      c = 0;
      d = 0;
      e = 0;
      f = binary[0];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  
  if(size == 2){
      a = 0;
      b = 0;
      c = 0;
      d = 0;
      e = binary[0];
      f = binary[1];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  
  if (size == 3){
      a = 0;
      b = 0;
      c = 0;
      d = binary[0];
      e = binary[1];
      f = binary[2];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  
  if (size == 4){
      a = 0;
      b = 0;
      c = binary[0];
      d = binary[1];
      e = binary[2];
      f = binary[3];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  
  if (size == 5){
      a = 0;
      b = binary[0];
      c = binary[1];
      d = binary[2];
      e = binary[3];
      f = binary[4];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  
  if (size == 6){
      a = binary[0];
      b = binary[1];
      c = binary[2];
      d = binary[3];
      e = binary[4];
      f = binary[5];
  
      cout &lt;&lt; a^d &lt;&lt; b^e &lt;&lt; c^f &lt;&lt; endl;
      return 0;
  }
  return 0;
  </code></pre>