+ 5

>> and << in python ?

what are these and how to use them.

3rd Jun 2018, 8:30 AM
Jatin Kumar
Jatin Kumar - avatar
3 Antworten
+ 8
They are bitwise operators, this link may help. https://www.sololearn.com/learn/4070/?ref=app e. g. 2 << 3 gives 16. 2 = 10 (in binary) then shift to the left by three digit. 10 turns into 10000 16 = 10000 (in binary)
3rd Jun 2018, 8:42 AM
李立威
+ 2
The idea is that it is a very fast way to multiply or divide by 2^k
4th Jun 2018, 9:11 AM
VcC
VcC - avatar
- 1
>> is moving all the bits one place to the right and << is the same, just to the left
4th Jun 2018, 9:45 AM
איתי יוסף
איתי יוסף - avatar