Intel Corporation interview question

write a function to see how many bits are set in an integer.

Interview Answers

Anonymous

1 Jul 2012

while(n>0){ (n&(n-1)) count++; }

Anonymous

12 Jul 2011

use bit wise operators. && and shift operators.