+ 1
How does this code work? print(5>>2) (Python)
print (5>>2) -> Output 1
4 Antworten
+ 5
David this code explains the shift right bitwise operator
https://sololearn.com/compiler-playground/cc8GLRo2i21c/?ref=app
additionally you might like this to explain Binary and bitwise shift left and right ...
https://www.sololearn.com/Discuss/2265151/?ref=app
0
>> 2 means 2 raised to power of two (division)
So, it is 5/4 = 1.25.
In bit operation, all result must be an integer so you get 1. NOTE
>> 3 means 2 raised to power of 3 (division)
>> 4 means 2 raised to power of 4 (division)
And so on
The opposite is multiplication (<<)
0
Output 1
0
Output 1