What is the most efficient way to count the number of bits
which are set in a value?

Answer Posted / boomer

pseudo

int size is 32 bits...right?

for(i = 0 to 31)
{
count += (value & 1) //& = and oprator
shift left value
}

Is This Answer Correct ?    6 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is a house a mass structure?

646


Why isnt there a numbered, multi-level break statement to break out

595


State the difference between realloc and free.

641


What functions are used in dynamic memory allocation in c?

601


What does double pointer mean in c?

584






What is the argument of a function in c?

579


What are control structures? What are the different types?

606


write a proram to reverse the string using switch case?

2475


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

683


What is the difference between the expression “++a” and “a++”?

654


Why is void main used?

625


What is the difference between far and near in c?

607


What is static memory allocation?

611


What does typeof return in c?

640


What are the different types of linkage exist in c?

617