Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Find the how many bits is turned on in a numebr

unsigned int num_ones(unsigned int n) { 
unsigned int num = 0;
while(n) { num += (n&1); n >>= 1; }
return num; 
} 
 
PREVIOUS NEXT
Tagged: #Find #bits #turned #numebr
ADD COMMENT
Topic
Name
2+2 =