public int countBits(int num){
        int count=0;
        while(num > 0){
            num &= num-1;
            count++;
        }
        return count;
    }
http://www.geeksforgeeks.org/count-set-bits-in-an-integer/
src/com/interview/bits/CountBits.java