+ 1

Print (x >> 2)

During a challenge I got this question: x = 5 print(x >> 2) Can anyone explain to me what x >> 2 does?

10th Aug 2017, 6:34 AM
Daan van IJcken
Daan van IJcken - avatar
3 Respostas
+ 11
It shifts two bits to the right: 5 == 101 in binary Two shifts to the right makes it: 101 --> 010 --> 001 001 in binary is 1 in decimal So the result becomes 1
10th Aug 2017, 6:38 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
thanks
10th Aug 2017, 6:43 AM
Daan van IJcken
Daan van IJcken - avatar