Binary Shifts
- A binary shift is the term used for multiplying or dividing in binary
- A binary shift moves all the bits in a binary number a certain number of positions to the left or right
- When performing a logical binary shift to the left, the bits shifted from the end of the register are lost, and zeros are shifted in at the opposite end
- When performing a logical binary shift to the right, the bits shifted from the beginning of the register are lost, and zeros are shifted in at the opposite end
- When performing a logical binary shift, the positive binary integer is multiplied or divided according to the shift performed. A shift to the left is equivalent to multiplication by a power of 2, while a shift to the right is equivalent to division by a power of 2
- When performing a logical binary shift, the most significant bit(s) or least significant bit(s) are lost, depending on the direction of the shift
Binary shift walkthrough:
- E.g. shifting the binary number 11001100 to the left by two positions gives 00110000. The two bits shifted from the end are lost, and two zeros are shifted in at the opposite end
- E.g. shifting the binary number 11001100 to the right by two positions gives 00110011. The two bits shifted from the beginning are lost, and two zeros are shifted in at the opposite end
- E.g. shifting 11001100 to the left by two positions, is multiplying it by 22, or 4. The result is 00110000, which is equal to 4 times the original value
- Shifting the binary number 11001100 to the right by two positions, is dividing it by 22, or 4. The result is 00110011, which is equal to the original value divided by 4
Exam Tip
- Make sure you’ve got the same number of bits in your answer as there were in the question. Check your answer by converting the binary number to denary, working out your answer and converting it back again. Make sure to label this checking so the examiner knows it isn’t part of your working out