49 in binary is
110001
You shift this same value by 7, 6, 5, 4, ..., (7 - i)
bits.
So
00110001 >> 7 ==> 00000000 == 0
00110001 >> 6 ==> 00000000 == 0
00110001 >> 5 ==> 00000001 == 1
00110001 >> 4 ==> 00000011 == 3
...
You can use Integer.toBinaryString(int)
to get the binary representation of an integer value as a String
.