What do >> and << mean in Python?

后端 未结 7 1826
无人共我
无人共我 2020-12-04 09:44

I notice that I can do things like 2 << 5 to get 64 and 1000 >> 2 to get 250.

Also I can use >> in pri

7条回答
  •  情话喂你
    2020-12-04 10:02

    12 << 2

    48

    Actual binary value of 12 is "00 1100" when we execute the above statement Left shift ( 2 places shifted left) returns the value 48 its binary value is "11 0000".

    48 >> 2

    12

    The binary value of 48 is "11 0000", after executing above statement Right shift ( 2 places shifted right) returns the value 12 its binary value is "00 1100".

提交回复
热议问题