title: Find if a number is a power of two without math function or log function
body: <p>I want to find if a user entered number is a power of two or not.   </p>
  
  <p>My code doesn't work.</p>
  
  <pre><code>public class power_of_two
  {  
      public static void main(String args[])  
      {  
  
          Scanner in=new Scanner(System.in);
          System.out.println("Enter the number : ");
          int num = in.nextInt();
  
          int other = 1;  
          if(((~num) &amp; 1) == 1)  
          {  
              System.out.println("The number is a power of two");  
          }  
          else  
          {
              System.out.println("The number is a  NOT A power of two");  
          }
      }  
  } 
  </code></pre>
  
  <p>Let me know how can I find the power of two number.<br>
  For example 8 is a power of 2.<br>
  22 is <strong>not</strong> a power of 2, etc..</p>