title: How can I test whether a number is a power of 2?
body: <p>I need a function like this:</p>
  <pre><code>// return true if 'n' is a power of 2, e.g.
  // is_power_of_2(16) =&gt; true  
  // is_power_of_2(3) =&gt; false
  bool is_power_of_2(int n);
  </code></pre>
  <p>Can anyone suggest how I could write this?</p>