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
Tell me what are bitwise shift operators?
What are the different types of C instructions?
Why do we use main function?
How can I do serial ("comm") port I/O?
Explain what math functions are available for integers? For floating point?
Write a program to print factorial of given number using recursion?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What does the characters “r” and “w” mean when writing programs that will make use of files?
Explain 'bit masking'?
What is ## preprocessor operator in c?
Is javascript based on c?
Explain low-order bytes.
Explain what are reserved words?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What are the types of assignment statements?