AQA Computer Science 8525Topic 3.3 — Fundamentals of data representationFoundation & Higher
Everything a computer stores is a pattern of ones and zeros. This topic is about how the same binary building blocks are arranged to hold numbers, text, pictures, sound and compressed data, and how you work backwards from what is stored to what it means. It is the most calculation-heavy part of Paper 2, and the calculations are all variations on the same two ideas: count the bits, and read the pattern.
What you need to know
Adding binary numbers
Be able to add together up to three binary numbers. Students will need to be able to add together up to three binary numbers using a maximum of 8 bits per number, will only be expected to add together a maximum of three 1s in a single column, and answers will be a maximum of 8 bits in length with no carrying beyond the 8th bit. So this is a carefully bounded skill: you will never be asked for something harder.
Key fact: Add up to three 8-bit binary numbers; at most three 1s in a column, with no carry beyond the 8th bit.
The rule for adding
It is the same rule as in decimal, with two carried instead of ten: 1 + 1 = 10, so write 0 and carry 1. If three 1s land in the same column, that is 1 + 1 + 1 = 11, so write 1 and carry 1. Adding 0011 0101 and 0001 1111 gives 0101 0100.
Key fact: 1+1 = 10 in binary: write 0 and carry 1. Three 1s give 11: write 1 and carry 1.
Binary shifts
Be able to apply a binary shift to a binary number, using a maximum of 8 bits, and to understand and use only a logical binary shift. A logical shift moves every bit one place to the left or right and fills the space with zeros. Shifting left by one multiplies by 2; shifting right by one divides by 2, dropping any remainder.
Key fact: A logical shift moves every bit and fills with zeros; left doubles, right halves.
Two kinds of shift
A logical shift always fills with zeros. An arithmetic shift preserves the sign bit, so shifting a negative number right fills with ones. Only the logical shift is required here, and the specification says fractional representations are not needed, so a right shift simply discards the last bit.
Key fact: Only logical shifts are required: no fractional values, and the sign is not preserved.
When shifts are used
Describe situations where binary shifts can be used: binary shifts can be used to perform simple multiplication or division by powers of 2. So multiplying by 4 is two left shifts, dividing by 8 is three right shifts. This is much faster than repeated addition, and it is how a processor can scale a number in one or two instructions.
Key fact: Shifts multiply or divide by powers of 2: multiply by 4 is two left shifts.
Working it out
A good way to check a shift is to convert to decimal. 0011 0000 is 48; one left shift gives 0110 0000 which is 96, exactly double; one right shift gives 0001 1000 which is 24, exactly half. Write your answer in 8 bits even if the leading bits are zero, because the question will usually expect a fixed width.
Key fact: Check a shift by converting to decimal, and always give the answer as 8 bits.
Flashcards
What is the rule when you add two 1s in binary?
Write 0 and carry 1, because 1 + 1 = 10 in binary.
What do you write and carry when a column contains three 1s?
Write 1 and carry 1, because 1 + 1 + 1 = 11 in binary.
What is a logical binary shift?
A shift that moves every bit one place and fills the vacated space with zeros.
What does a left shift by one do to the value?
It multiplies the value by 2.
What does a right shift by one do to the value?
It divides the value by 2, discarding any remainder.
How would you multiply a binary number by 8 using shifts?
Apply three left shifts.
What is the maximum bit width for the shifts and additions in the exam?
8 bits, and no carrying beyond the 8th bit.
Exam questions
Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.
mcq1 mark
What is the effect of a single logical left shift on a binary number?
It halves the value
It adds 1 to the value
It doubles the value
It reverses the bits
Mark scheme: 1 mark for identifying that a left shift multiplies the value by 2, because each bit moves one place to a value twice as large.
calc2 marks
Add the binary numbers 0011 0101 and 0001 1111, giving the answer as 8 bits.
Answer: 0101 0100 (which is 84 in decimal).
six6 marks
Explain in English how binary addition and binary shifts work, and where shifts are useful.
Mark scheme: Level 1 (1-2 marks): A short answer saying binary addition carries 1 and a left shift doubles the number. Level 2 (3-4 marks): A structured answer covering the addition rule and the two kinds of shift. Level 3 (5-6 marks): A detailed answer explaining that binary addition uses the same carry rule as decimal but with 2 as the base, showing what happens with two and with three 1s in a column, explaining that a logical shift moves every bit and fills with zeros while shifting left doubles and shifting right halves, noting that only logical shifts on whole numbers are required, and explaining that shifts give fast multiplication or division by powers of 2, so multiplying by 4 is two left shifts.