Pergunta de entrevista da empresa Amazon

how to get the most significant bit from a byte?

Respostas da entrevista

Sigiloso

23 de jun. de 2013

If he was asking about converting a decimal integer number into binary and getting the most significant bit out of it, then the answer is just: divide by 2, again and again until you get the last '1'; Or using programming code: while(x) { x >>= 1; ++n; }

Sigiloso

18 de abr. de 2012

I couldnt understand what he ment by byte. I thought eight bits in binary format. But what he was asking about converting a decimal number into binary and getting the most significant bit out of it.

Sigiloso

24 de abr. de 2012

right shift the number by 7 positions and you get the most significant bit printf("%d",n>>7);