What does a bitwise shift (left or right) do and what is it used for?

前端 未结 9 2174
傲寒
傲寒 2020-12-02 05:00

I\'ve seen the operators >> and << in various code that I\'ve looked at (none of which I actually understood), but I\'m just wondering

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 05:33

    The bit shift operators are more efficient as compared to the / or * operators.

    In computer architecture, divide(/) or multiply(*) take more than one time unit and register to compute result, while, bit shift operator, is just one one register and one time unit computation.

提交回复
热议问题