Count the 1s in the number
Anonymous
#define INTSIZE(16) int ones_counter(unsigned int num) { unsigned int counter = 0; for (i = 0; i < INTSIZE; ++i) { if ((1 << i) & num) counter++; } return (counter); }
Check out your Company Bowl for anonymous work chats.