I am using python to do some work which need I do some math like this
c = bitshift(a, b); %this is matlab code which just shift c to left b bits.
if a = '1111111' then after this bitshift, it should be
c = '1111110'
a = 255
b = a <<1
You are doing a bit shift.
Keep in mind that
000...011111111 (usually 32 bits for integer).
0000000011111111 0000000111111110 0000001111111100
and so on, but the computer doesn't print the zeros in the beginning.
if you want to limit your number to 8 bits, use the
& (bitwise and) operator:
var & 255, that will bring only the most right 8 bits.