57 exam-style questions plus unlimited generated ones on this topic, at up to four difficulty levels, with full mark schemes. Notes and past-paper booklets are open to everyone. Practice needs a free account.
Or take a quick quiz: 12 questions on this subtopic in GCSE Computer Science (OCR), marked as you tap.
Adding two binary numbers of up to 8 bits, explaining overflow errors, and carrying out left and right binary shifts and describing their effect on the value. Expect short calculations (1 to 3 marks) plus 'explain' marks about overflow and lost bits.
Key facts
0 + 0 = 0; 0 + 1 = 1; 1 + 1 = 10; 1 + 1 + 1 = 11
Largest 8-bit value: 11111111 = 255
Overflow: the result is too large for the number of bits available
Left shift n places = × 2n (× 2, × 4, × 8 …)
Right shift n places = ÷ 2n (any remainder is lost, so the result rounds down)
Check your answer by converting all three numbers to denary.
Overflow
diagram
8 bits can hold a maximum value of 255. A result bigger than 255 needs a 9th bit.
An overflow error happens when the result of a calculation is too large to be stored in the number of bits available.
The carry out of the most significant bit is lost, so the stored result is wrong. E.g. 11000000 (192) + 01010000 (80) = 100010000 (272), but only 00010000 (16) is stored.
Overflow: the answer needs 9 bits, so the carry out of the most significant bit is lost
Overflow can cause a program to give wrong results or crash. It can be prevented by using more bits (e.g. 16) or by checking whether the result will fit before storing it.
Binary shifts
diagram
Left shift: move every bit left by the given number of places and fill the empty places on the right with 0s. Each place multiplies the value by 2: 1 place × 2, 2 places × 4, 3 places × 8.
E.g. 00010101 (21) shifted left 2 places → 01010100 (84) = 21 × 4.
Left shift 2 places: every bit moves 2 places left, 0s fill the right, value × 4
Right shift: move every bit right and fill the empty places on the left with 0s. Each place divides the value by 2.
E.g. 01101000 (104) shifted right 3 places → 00001101 (13) = 104 ÷ 8.
Bits pushed off the end are lost. If a 1 is lost on a right shift, the result is rounded down (loss of precision): 00001011 (11) shifted right 1 place → 00000101 (5), not 5.5. Grade 7+ only
If a 1 is lost off the left on a left shift, the true answer is too big for 8 bits, so the result is wrong: 10100000 (160) shifted left 1 place → 01000000 (64), not 320. Grade 7+ only
How to answer each type of question
Add two 8-bit binary numbers
2 marksGrade 5
Write the numbers one above the other, lined up on the right.
Add each column from right to left using the four rules, writing carries clearly.
Give the 8-bit answer, and mention overflow if there is a carry out of the left-hand column.
Check by converting to denary.
Example. Add the binary numbers 00111001 and 01010110. Give your answer as an 8-bit binary number. Show your working. [2]
Work out the true result (in denary or as a 9-bit number).
Say that it is more than 255 / needs more than 8 bits.
Say that the extra bit is lost, so the stored result is wrong.
Example. The 8-bit numbers 10110100 and 01100000 are added together. Explain why an overflow error occurs. [2]
Show the model answerHide the model answer
The result is 276 (100010100), which is greater than 255 / needs 9 bits (1). Only 8 bits are available, so the carry out of the most significant bit is lost and the stored result (00010100 = 20) is wrong (1).
Carry out a binary shift and state its effect
2 marksGrade 6
Move every bit the stated number of places in the stated direction.
Fill the empty places with 0s and keep the answer to 8 bits.
State the effect: multiply (left) or divide (right) by 2, 4, 8 …
Example. (a) Perform a left binary shift of 3 places on 00001011. [1] (b) State the effect of this shift on the value of the number. [1]
Show the model answerHide the model answer
(a) 01011000
(1)
(b) The number is multiplied by 8 (11 becomes 88)
(1)
Explain the effect of a shift that loses bits
2 marksGrade 7
Carry out the shift.
Identify which 1s have been shifted off the end.
Explain the effect: rounded down (right shift) or wrong because of overflow (left shift), using denary values.
Example. The binary number 00100111 is shifted 2 places to the right. Give the result and explain why it is not exactly a quarter of the original value. [2]
Show the model answerHide the model answer
00001001 (1). The two right-hand 1s are shifted off and lost, so the result is 9 instead of 39 ÷ 4 = 9.75: it has been rounded down (loss of precision) (1).
Don’t lose marks
Forgetting a carry, especially in a column with 1 + 1 plus a carry.
Writing a 2 in a column: binary digits can only be 0 or 1.
Filling empty places with 1s after a shift, or wrapping the lost bits round to the other end.
Saying overflow means 'the number is too big' without saying 'for the number of bits available'.
Giving a 9-bit answer when an 8-bit answer is asked for, without mentioning overflow.
More tips
Memory tricks
Count the 1s in a column, including any carry: 0 → write 0; 1 → write 1; 2 → write 0, carry 1; 3 → write 1, carry 1.
Left = larger (multiply); right = reduced (divide).
Check any binary addition in denary: a total over 255 means overflow in 8 bits.
Shift by n places means × or ÷ by 2n: 1 place → 2, 2 places → 4, 3 places → 8, 4 places → 16.
Exam technique
Show the carries: if your final answer has a slip, clear working can still earn a mark.
Use numbers in overflow explanations: 'the total is 276, but 8 bits can only store up to 255'.
For shift questions, give the new number with all 8 bits, then the effect (× or ÷ by 2, 4, 8 …).
What each grade needs
What you need to be able to do, from the first marks up to the top grade.
Add two 8-bit binary numbersWork from right to left, writing each carry clearly under the next column.
Grade 5
Carry out a left or right shiftMove every bit the given number of places and fill the empty places with 0s.
Grade 6
Explain what an overflow error isThe result of a calculation is too large to be stored in the number of bits available, e.g. more than 255 in 8 bits.
Grade 6
State the effect of a shiftEach place of left shift multiplies by 2; each place of right shift divides by 2.
Grade 7
Explain the effect of bits being lost1s shifted off the right make the result round down; 1s shifted off the left make the result wrong (overflow).
Grade 8
Solve problems combining shifts and additionE.g. multiply by 10 by adding the results of a left shift of 3 places (× 8) and a left shift of 1 place (× 2), and spot when overflow will happen.
Quick recall
Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.
Add the binary numbers 0101 and 0011. Give your 4-bit answer.
1000
An 8-bit binary number is shifted left by 1 place. State the value of the bit that is added at the right-hand end of the number.
0
A binary number is shifted right by 1 place. State what happens to the bit that moves past the right-hand end of the register.
It is lost (discarded).
State the largest denary number that can be stored in an 8-bit binary register.
255
Two 8-bit binary numbers are added together. The correct answer is 100000000. State how many bits are in this answer.
9
Statement 1: ‘Adding two 8-bit binary numbers always gives an answer that can be stored in 8 bits.’ Write true or false and give a reason.
False. The answer can be greater than 255 and need 9 bits.
Sample questions
Written for this site in the style of OCR exam questions. They are not taken from real past papers.
Question 1Easy3 marks
(a) What is the result of the binary addition 1 + 1? Tick (✓) one box.
[1]
10
2
11
01
(b) State the effect on the value of a binary number of a left shift of one place.
[1]
(c) State the effect on the value of a binary number of a right shift of two places.
[1]
Show the answer and mark scheme
(a)Answer: 10
(b)
it is multiplied by 2 / doubled
(c)
it is divided by 4
Question 2Medium3 marks
(a) Explain what is meant by an overflow error.
[2]
(b) State one possible consequence of an overflow error in a program.
[1]
Show the answer and mark scheme
(a)
the result of a calculation is too large
to be stored in the number of bits available, e.g. greater than 255 in an 8-bit register
(b)
an incorrect result is stored / displayed / the program crashes / data is corrupted
Question 3Hard3 marks
A student added two 8-bit binary numbers. Their working is shown.
01101011
+ 00110110
----------
10000001
The student's answer is wrong because they forgot to include one carry.
(a) Give the correct answer as an 8-bit binary number.
[1]
(b) Identify the place value of the column where the student forgot to include the carry.
[1]
(c) Convert the two numbers being added and your correct answer into denary to show that your answer is correct.