Binary addition, shifts and overflow
Computer Science · Foundations
Question 1 of 10
0A logical left shift of 1 place is applied to the 8-bit binary number 0101 0100. Give the denary value of the result.
Decimals (0.75 or 0,75), fractions (3/4) and mixed numbers (1 1/2) are accepted. Do not use thousands separators.
How to type your answer
- Fractions: 3/4. Mixed numbers: 1 1/2.
- Decimals with a point or a comma: 0.75 or 0,75.
- Negative numbers start with a minus: -3/4.
- Percentages need the % sign: 75%.
Stuck? Read the explanation
Unlocks at a streak of 5 correct answers in a row.
Embed this practice on your site or class page
Paste this HTML into your page. Students practise right there; it is free and needs no account.
Binary addition, shifts and overflow explained
Binary addition works like decimal addition, but with only two digits. The rules are , and , which writes 0 and carries 1 into the next column. When three 1s are added in one column, the result is , a 0 with a carry of 1.
A logical shift moves every bit along the register by a given number of places. Shifting left by one place multiplies the number by 2, and shifting right by one place divides it by 2, discarding any remainder. Empty places are filled with 0s.
Overflow happens when the result of a calculation needs more bits than the register can hold. In an 8-bit register the largest value is 255, so any larger result is cut down to its last 8 bits. The carry out of the top bit is lost, and the stored answer is wrong. Programmers must check for overflow when the result could be large.
Worked example
Add 200 and 100 using 8-bit registers, then shift 11 two places to the left.
- and .
- Adding gives , which needs 9 bits.
- The 8-bit register keeps and the carry is lost. This is overflow, because .
- Shifting left by two places gives , which is .
What you will practise
New numbers every time you practise. Levels: Easy, Medium, Hard. Each answer is followed by a worked explanation.
Example questions
Easy
A logical right shift of 1 place is applied to the 8-bit binary number 1100 1000. Give the denary value of the result.
Medium
A logical left shift of 2 places is applied to 0011 1110. Give the denary value of the result.
Hard
The 8-bit number 1101 1000 is logically shifted left by 4 places in an 8-bit register. How many 1 bits are lost off the left end?