Veritas (Georgia) Interview Question: write code to count the numbe... | Glassdoor

Interview Question

Senior Staff Engineer Interview Mountain View, CA

write code to count the number of bits in a byte


Interview Answer

1 Answer


use a bit mask (0x01) and btiwise & it with the number.
Keep left shifting the bitmask 8 times and increment count each time the answer of the bitwise & is 1.

Interview Candidate on Mar 24, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.