title: Tell if a 32 bit signed int is a power of 2
body: <p>I need to determine if a signed 32 bit number is a power of two. So far I know the first thing to do is check if its negative since negative numbers cannot be powers of 2. 
  Then I need to see if the next numbers are valid etc... SO I was able to write it like this:</p>
  
  <pre><code>// Return 1 if x is a power of 2, and return 0 otherwise.
  int func(int x)
  {
       return ((x != 0) &amp;&amp; ((x &amp; (~x + 1)) == x));
  }
  </code></pre>
  
  <p>But for my assignment I can only use 20 of these operators:</p>
  
  <pre><code>! ~ &amp; ^ | + &lt;&lt; &gt;&gt;
  </code></pre>
  
  <p>and NO equality statements or loops or casting or language constructs. </p>
  
  <p>So I am trying to convert the equality parts and I know that !(a^b) is the same as a == b but I cant seem to figure it out completely. Any ideas on how to covert that to the allowed operators?</p>