title: What is the best way to determine if a given number is a power of two?
body: <p>I need to return <code>true</code> if the <code>n</code> is a power of two and <code>false</code> otherwise. It should go something like:</p>
  <pre><code>function isPowerOfTwo(n) {
    // Code here
  }
  </code></pre>
  <p>This is the way I currently do it:</p>
  <pre><code>function isPowerOfTwo(n) {
    var x = Math.pow(2, Math.round(Math.log(n) / Math.log(2)));
    return x;
  }
  </code></pre>
  <p>Are there any more effective ways?</p>