title: Time complexity for finding whether a given number is a power of 2
body: <p>I am trying to calculate the time complexity for a function return below-</p>
  
  <pre><code>int isPowerof2(unsigned int num)
  {
       if(((~num)&amp;1) == 1)
            return 1;
        return 0;
  }
  </code></pre>
  
  <p>I think it should be O(1) but i am not sure the complexity for negation. Can somebody please help me in understanding how to identify the complexity for this. Thanks!</p>
  
  <p>Edit- What if in case of a single number consider it as an n inputs and the functions checks for power of 2 , what would be the complexity in that case</p>