title: What n&1 and n>>=1 mean?
body: <p>I was doing this exercise : <a href="https://www.hackerrank.com/challenges/30-binary-numbers/problem" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/30-binary-numbers/problem</a> and I found this &quot;smart&quot; code on the net, but I didn't understand what the condition with n&amp;1 and n&gt;&gt;=1 do here.</p>
  <pre><code> //C++ program to convert a decimal
  // number to binary number
  
  #include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      int n,count=0,max=0;
      cin &gt;&gt; n;
  
      while(n)
      {
          if (n&amp;1)
              count++;
          else
              count = 0;
          if (max &lt; count)
              max = count;
          n&gt;&gt;=1;
      }
      cout &lt;&lt; max;
  
      return 0;
  }
  </code></pre>