+ 1

Bitwise operator

Can somebody explain why this results in 32? x=5 print(x>>2<<x) I know 5>>2 is 1 And 2<<5 is 64. Where does the 32 come from?

25th Nov 2017, 5:43 AM
Mikelforce
Mikelforce - avatar
3 odpowiedzi
+ 3
x = 5 (0000 0101) 1. 5 >> 2 (0000 0001) = 1 2. 1 << 5 (0010 0000) = 32
25th Nov 2017, 7:35 AM
Boris Batinkov
Boris Batinkov - avatar
0
Got it. Thanks!
25th Nov 2017, 6:23 AM
Mikelforce
Mikelforce - avatar