title: What is the rationale for == having higher precedence than bitwise AND, XOR, and OR?
body: <p>In C++, what is the rationale for == and != having higher precedence than bitwise AND, XOR, and OR?</p>
  
  <p>It would seem to me more natural to have <code>operator==</code> and <code>operator!=</code> come after <code>operator&amp;</code>, <code>operator^</code>, and <code>operator|</code>.  I'd like to understand the motivation so that I can better remember the ordering.</p>
  
  <p>For example, I would think the following kind of usage would be common:</p>
  
  <pre><code>if (bitFields &amp; value == 0) { // Incorrect test.
    // Do Something.
  }
  </code></pre>
  
  <p>Since the == result is either 1 or 0, why would you ever want to use it for bitwise operations?  Instead, the above must be written as:</p>
  
  <pre><code>if ((bitFields &amp; value) == 0) { // Correct test.
    // Do Something.
  }
  </code></pre>
  
  <p>to get the intended meaning where the bitwise AND is done before the comparison to zero.</p>