Can anyone explain why '>>2' shift means 'divided by 4' in C codes?

后端 未结 10 1466
谎友^
谎友^ 2020-12-05 09:25

I know and understand the result.

For example:


7 (decimal) = 00000111 (binary)
and 7 >> 2 = 00000001 (binary)
10条回答
  •  庸人自扰
    2020-12-05 09:47

    Its inherent in the binary number system used in computer.

    a similar logic is --- left shifting 'n' times means multiplying by 2^n.

提交回复
热议问题