Mtech1
Junior Member level 1

I am having difficulties understanding how to shift bits that are not in sequence.
I understand shifting bits in sequence, like (7 to 4) or (7, 6). For instance, shifting the higher nibble to the right is achieved by using 'byte = byte >> 4,' resulting in 0000 11100.
Similarly, shifting only two bits (7, 6) to the right is done with 'byte = byte >> 2,' which gives 0000 0011.
However, I'm struggling to understand how to perform bit shifts for non-sequential positions like (6, 3) or (4, 2).
For example, if we take the byte 1100 0101 and want to shift the bits (6, 3) to the right, or (4, 1), it's not clear to me how to perform these bit shifts.
I understand shifting bits in sequence, like (7 to 4) or (7, 6). For instance, shifting the higher nibble to the right is achieved by using 'byte = byte >> 4,' resulting in 0000 11100.
Similarly, shifting only two bits (7, 6) to the right is done with 'byte = byte >> 2,' which gives 0000 0011.
However, I'm struggling to understand how to perform bit shifts for non-sequential positions like (6, 3) or (4, 2).
For example, if we take the byte 1100 0101 and want to shift the bits (6, 3) to the right, or (4, 1), it's not clear to me how to perform these bit shifts.