Simple question. I know it's a logical shift. But does it mean it shifts in an 1? or just 1 to the right? If it's not shifting in an 1, is it a circular shift? I've googled this, but there's a lot of conflicting information out there. Thanks.
1
votes
4 Answers
3
votes
Logical shift right, 1 bit.
So 1001b >> 1 = 0100
It will pad a 0 to left left and shift all the bits to the right by what ever number you are shifting, so 1 bit. user3372159 is right that a flag will be set in the processor with the bit that was shifted off, but you will need some assembly knowledge to work with it, or just use more binary operations to get the first bit before shifting.
It's useful for many things, but notably for dividing/multiplying by 2.
10 = 1010b
1010b >> 1 = 0101b = 5
0101b << 1 = 1010b = 10
3
votes
0
votes