Subj : how does this work To : comp.programming From : pacman2081 Date : Sun Jul 31 2005 05:20 pm This piece of code counts the number of one bits in integer x. unsigned int x; x = (x & 0x55555555) + ((x>>1)&0x55555555); x = (x & 0x33333333) + ((x>>2)&0x33333333); x = (x & 0x0F0F0F0F) + ((x>>4)&0x0F0F0F0F); x = (x & 0x00FF00FF) + ((x>>8)&0x00FF00FF); x = (x & 0x0000FFFF) + ((x>>16)&0x0000FFFF); I have not been able to figure out how. -- pacman .