>> operator in Python

后端 未结 5 1641
无人及你
无人及你 2020-11-30 08:48

What does the >> operator do? For example, what does the following operation 10 >> 1 = 5 do?

5条回答
  •  没有蜡笔的小新
    2020-11-30 09:04

    It's the right bit shift operator, 'moves' all bits once to the right.

    10 in binary is

    1010

    shifted to the right it turns to

    0101

    which is 5

提交回复
热议问题