title: How does this bitwise operation check for a power of 2?
body: <p>I'm looking at some code which should be trivial -- but my math is failing me miserably here.</p>
  
  <p>Here's a condition that checks if a number if a power of 2 using the following:</p>
  
  <pre><code>if((num != 1) &amp;&amp; (num &amp; (num - 1))) { /* make num pow of 2 */ }
  </code></pre>
  
  <p>My question is, how does using a bitwise AND between num and num - 1 determine if a number is a power of 2?</p>