I need explanation for “Bit Counting” challenge on codewars platform.
The instruction says:
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.
Example : The binary representation of 1234 is 10011010010 , so the function should return 5 in this case
So I did not understand how do we return 5 and what should I do to return 5 and why the answer is 5?
However, the question is not about finding the total number of bits. It asks for “the number of bits that are equal to one in the binary representation”, for which the code from Jame’s qpost neatly solves.