title: Count number of 1's in binary format of decimal number
body: <p>I am trying to find out the number of 1's in binary form of a large decimal number (decimal number can be as large as 1000000).</p>
  
  <p>I tried this piece of code:</p>
  
  <pre><code>while(sum&gt;0)  
  {  
      if(sum%2 != 0)  
      {  
          c++;   // counting number of ones  
      }  
      sum=sum/2;  
  }  
  </code></pre>
  
  <p>I want a faster algorithm as it takes long time for large decimal input. Please suggest me an efficient algorithm.</p>