+ 1

symbol

Anyone knows what this symbol“>>” means? print(2>>2) #Output:0 print(3>>2) #Output:0 print(4>>2) #Output:1 print(8>>2) #Output:2 print(10>>2) #Output:2 print(12>>2) #Output:3 I really curious about how this symbol made the output🥴

28th Jun 2022, 2:16 AM
Loo Jia Xin
Loo Jia Xin - avatar
3 Respostas
+ 2
This is what I found by searching"right shift operator": Takes two numbers, right shifts the bits of the first operand, the second operand decides the number of places to shift. In other words right shifting an integer “x” with an integer “y” denoted as ‘(x>>y)‘ is equivalent to dividing x with 2^y.  eg: lets take N=32; which is 100000 in Binary Form.      Now, if “N is right-shifted by 2” i.e N=N>>2 then N will become N=N/(2^2). Thus, N=32/(2^2)=8 which can be written as 1000.
28th Jun 2022, 2:57 AM
Loo Jia Xin
Loo Jia Xin - avatar
+ 3
Look for bitwise right shift in this https://www.sololearn.com/learn/4070/?ref=app
28th Jun 2022, 2:36 AM
Ipang
+ 1
Thanks Ipang, it really helps me!
28th Jun 2022, 2:56 AM
Loo Jia Xin
Loo Jia Xin - avatar