Pregunta de entrevista de Amazon

Write a function that takes an integer and counts the number of bits.

Respuestas de entrevistas

Anónimo

14 ene 2012

This is a simple bit manipulation problem. If you study before your interviews, this is a common area to study.

Anónimo

17 nov 2012

void count_Bits(int inp){ int count = 0; for (int y = inp; y >=1;y = y /2 ){ count++; } cout<< "number of bits : " << count<< endl; }

Anónimo

22 jul 2013

If you take a simple log base 2 of the integer, that should give you the number of bits, right?