Java Bit Operation on Long - Counting Set and Unset bits
<p>I have a long number. Now what I want is following (given in pseudo code) ,</p>

<pre><code>int cnt1 = 0 
int cnt2 = 0 

for each two bits of that long

       if the two bits == 11
            then cnt1++

       else
            cnt2++

    Print i and i+1 th bits are ... (example 00, 11 etc.) and cnt1 = ... and cnt2 = ...

(for example if number is three (representation "00 00 00 .... 11)" 
  it will give output cnt1 = 1 and cnt2 = 31)
</code></pre>

<p>Can anybody help me how to do that ?</p>
