public static int countSetBits(long number){ int count = 0; while(number>0){ ++count; number &= number-1; } return count; }