Wednesday, June 20, 2007

Number Game!

Consider that you have a 32 bit machine and you have a number such as say Hex CF39. How would you go about counting the number of 1's in the binary representation of this number? In other words, the binary representation of CF39 is 1100111100111001. What is needed is a way to count the number of 1's in this number i.e the answer should be 10.[ Your 32 bit machine doesn't have an instruction that can do this :-) ]

No comments: