Pergunta de entrevista da empresa Veritas (Georgia)

write code to count the number of bits in a byte

Resposta da entrevista

Sigiloso

25 de mar. de 2010

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.