title: How to replace this if/else statement with bitwise operations?
body: <p>I am doing bitwise &amp; between two bit arrays saving the result in old_array and I want to get rid of the if/else statement. I should probably make use of the BIT_STATE macro, but how?</p>
  
  <pre><code>#define BYTE_POS(pos) (pos / CHAR_BIT)
  #define BIT_POS(pos) (1 &lt;&lt; (CHAR_BIT - 1 - (pos % CHAR_BIT)))
  #define BIT_STATE(pos, state) (state &lt;&lt; (CHAR_BIT - 1 - (pos % CHAR_BIT)))
  
  if (((old_array[BYTE_POS(old_pos)] &amp; BIT_POS(old_pos)) != 0) &amp;&amp; 
     ((new_array[BYTE_POS(new_pos)] &amp; BIT_POS(new_pos)) != 0))
  {
     old_array[BYTE_POS(old_pos)] |= BIT_POS(old_pos);
  }
  else
  {
        old_array[BYTE_POS(old_pos)] &amp;= ~(BIT_POS(old_pos));
  }
  </code></pre>