I think shrik3's solution is the most efficient -- shift right, use the LSB (least significant bit), mask with "1", then no need to test/compare since the result of the mask is all ready to add to the count.
CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.
@Acer
Trying to think of applications of that function... error detection, image processing, and maybe signal processing? I don't know...