Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
#include<stdio.h> main() { int x=123,i=0; while(x) { x=x&(x-1); i++; } printf("Number of set bits are %d \n",i); }