Binary Shift
Learn binary shift and test your knowledge!
- How to do Binary Shift
- How to Convert Binary Numbers Using Power of 2 Rule
- Binary Shift Demo
- Binary Shift Game
How to do Binary Shift
To perform a binary shift, add 0s to the opposite end of the direction asked (if left, add 0 on the right end and vice versa). Then, shift all the numbers down in the direction (left/right) and discard the numbers shifted out of the ends. See image below for an example.
How to Convert Binary Numbers Using Power of 2 Rule
Binary numbers are made up of 0s and 1s, each corresponding to a power of two based on its position. Starting from 1 on the right end, multiply by two each bit to the left. To find the binary number, add the powers of 2 that the 1s coordinate with. A left shift is used to multiply the binary number by 2, and a right shift is used to divide the binary number by 2.
In the example below, the binary number has 8 bits meaning the highest power of 2 reaches 128, and the binary number is 16 + 4 + 1 = 21. When shifted to the left, the binary number becomes 42 since it is multiplied by 2. Check: 32 + 8 + 2 = 42. When shifted to the right, the binary number becomes 10 since it is divided by 2. Check: 8 + 2 = 10.
Binary Shift Demo
Binary Number: 01011101
Binary Shift Game
In this game, you select which direction of shift you want to perform on a randomly generated binary number using the buttons below. After choosing left or right, you will be asked to shift the binary number in that direction by 1 position.
After submitting the first question, you will be asked to convert another randomly generated binary number to decimal form.