title: Find out if a number is a power of 2 using Bitwise Operators [O(1)]
body: <p>Hey I have a quick question:</p>
  
  <p>How do I find out if an int is a <strong>power of 2</strong> (only 1 positive bit) using bit-wise operators, in <strong>O(1)</strong> without any <strong>IF</strong> statements or any other type of <strong>BOOLEAN</strong> expression? </p>
  
  <p>The method needs to return an integer value.</p>
  
  <p>The method can return a certain number that you can decide on that means its a power of 2 and another number that means its not a power of 2. [Saying negative number means X and positive means Y is also allowed]</p>
  
  <p>Also
  you can not rely on the fact that an int has 32 bits. </p>
  
  <p>This is a question I was asked in an interview.</p>