title: Why does the following bitwise operation return an unintended result?
body: <p>3 bits can hold up to a maximum number of 7 (4 + 2 + 1).  I'm trying to calculate this using a bitwise operation.</p>
  
  <pre><code>3 is 0b011 
  ~3 is 0b100
  </code></pre>
  
  <p>Doing a bitwise OR I would expect 0b111 (i.e. 7).  Instead I get</p>
  
  <pre><code>int result = (~3) | 3;
  printf("%i\n", result);
  </code></pre>
  
  <blockquote>
    <p>-1</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>