1.2.4

Data storage

How numbers, text, images and sound are stored in binary and the effect on size and quality.

Learning Objectives

  • 1Convert positive denary whole numbers to binary (up to 8 bits) and back
  • 2Add two binary integers and explain overflow
  • 3Convert between denary, binary and hexadecimal
  • 4Carry out and explain the effect of a binary shift
  • 5Explain how characters, images and sound are represented in binary

Converting denary to binary

Computers only understand binary (0s and 1s), so ordinary "denary" (base 10) numbers must be converted into binary to be stored. In this course you convert whole numbers up to 8 bits, so denary 0 to 255. Each position in an 8-bit binary number is worth a power of 2: 128, 64, 32, 16, 8, 4, 2, 1. To convert denary to binary, work out which of these place values add up to your number, putting a 1 in that column and a 0 everywhere else. The bit on the far left (worth 128) is the most significant bit (MSB), because it is worth the most; the bit on the far right (worth 1) is the least significant bit (LSB). Adding zeros to the front never changes the value, so 11010 is the same number as 00011010.
Denary (base 10) numbers must be converted to binary to be stored and processed. This course covers whole numbers up to 8 bits (denary 0-255). An 8-bit binary number has place values 128, 64, 32, 16, 8, 4, 2, 1 (each one double the last). To convert denary to binary, subtract the largest place value that fits, place a 1 there, and repeat with the remainder until you reach 0. The leftmost bit is the most significant bit (MSB) and the rightmost is the least significant bit (LSB). You may be given a number with fewer than 8 bits: leading zeros do not change the value, so 11010 is the same as 00011010.
Converting denary to binary means expressing the number as a sum of powers of 2 (128, 64, 32, 16, 8, 4, 2, 1 for 8 bits), placing a 1 in each place value used and 0 elsewhere. The leftmost bit is the most significant bit (MSB), the rightmost is the least significant bit (LSB). E.g. 11010 is equivalent to 00011010, leading zeros don't change the value.
8-bit place valuesMSB (most significant bit)LSB (least significant bit)Place valueBitContributes12800640032132160081841420011132 + 8 + 4 + 1= 45Add only the columns with a 1 in them

Think of it like...

Think of it like making a number out of coins worth 128, 64, 32... down to 1: you always grab the biggest coin that still fits, then keep going with whatever's left.

Converting binary to denary

To convert binary back to denary, write the place values (128, 64, 32, 16, 8, 4, 2, 1) above each bit, then add up the place values where there is a 1. For example, 00101101 = 32 + 8 + 4 + 1 = 45.
Converting binary to denary: line up each bit under its place value (128, 64, 32, 16, 8, 4, 2, 1) and add together the place values where the bit is 1. E.g. 00101101 = 32 + 8 + 4 + 1 = 45.
Binary-to-denary conversion sums the place values corresponding to each 1 bit. The largest 8-bit binary number, 11111111, equals 255 (128+64+32+16+8+4+2+1); the smallest, 00000000, equals 0. Watch out for off-by-one errors, an 8-bit number has a maximum of 255, not 256.

Binary addition and overflow

You can add two binary numbers together just like denary, but carry a 1 to the next column whenever a column adds up to 2 or more (since binary only has 0 and 1). If adding two 8-bit numbers produces a result that needs a 9th bit, there isn't room for it, this is called an overflow error.
Binary addition works column by column from the right, carrying 1 into the next column whenever the total in a column is 2 (write 0, carry 1) or 3 (write 1, carry 1). If the result of adding two 8-bit numbers needs a 9th bit to be stored correctly, the extra bit is lost, this is an overflow error, and the stored result will be wrong.
Binary addition proceeds bit by bit with carries, identical in principle to denary column addition. An overflow error occurs when the sum of two n-bit numbers requires n+1 bits, the register or storage location cannot hold the extra bit, so it is discarded and the result is incorrect. Always show carries explicitly in working, converting to denary, adding, then converting back may give the right final answer but does not demonstrate the binary method and can lose working marks.
Adding two 8-bit binary numbersCarry1110001011022+00001101130010001135Column rules0 + 0 = 00 + 1 = 11 + 1 = 0, carry 11 + 1 + 1 = 1, carry 1Work right to leftThe answer still fits in 8 bits, so there is no overflow.Overflow happens when a carry comes out of the left-most column and the answer needs a 9th bit.

Converting to and from hexadecimal

Hexadecimal (hex) is a base-16 number system using the digits 0-9 and then A-F for 10-15. This course uses 2-digit hex (00 to FF), matching one byte. Each hex digit represents exactly 4 bits (one nibble), so a byte splits neatly into two hex digits. Hex is used because it is much shorter to write and read than binary, for example FF is much easier to work with than 11111111.
Hexadecimal is base 16, using digits 0-9 then A-F (A=10 ... F=15). This course covers 2-digit hex, 00 to FF, the same range as one byte. Each hex digit maps to exactly 4 bits, so to convert binary to hex, split the byte into two nibbles and convert each nibble separately; to convert hex to binary, convert each hex digit into its 4-bit binary equivalent and join them. To convert denary to hex, divide by 16 (the quotient is the first digit, the remainder is the second).
Hexadecimal's usefulness comes from the exact 4-bit-per-digit mapping to binary, unlike denary, converting hex ↔ binary never requires long division, just per-nibble substitution. Denary ↔ hex conversion uses base-16 place values (16s and 1s for 2-digit hex). Hex is widely used in computing to represent binary values (e.g. MAC addresses, colour codes) far more compactly and readably than raw binary.
Hex digit and its 4-bit binary (nibble)HexBinary00000100012001030011HexBinary40100501016011070111HexBinary8100091001A1010B1011HexBinaryC1100D1101E1110F1111A byte splits into two nibbles, so one byte is always exactly two hex digits:1011 0110→B6

Binary shifts

A binary shift moves every bit in a binary number left or right by a set number of places, filling the empty spaces with 0s. Shifting left by one place multiplies the number by 2; shifting right by one place divides it by 2 (rounding down). For example, shifting 00000011 (3) left by 2 places gives 00001100 (12), 3 × 2 × 2.
A binary shift moves all the bits left or right by a given number of places, with 0s filling the gaps left behind (bits shifted off the end are lost). Each left shift by one place doubles the value; each right shift by one place halves it (rounding down, remainder discarded). A shift left by n places multiplies by 2n; a shift right by n places divides by 2n.
Binary shifts are a fast way to multiply or divide by powers of 2 in hardware. A left shift by n is equivalent to ×2n; a right shift by n is equivalent to integer division by 2n. Bits shifted beyond the register's width are lost (which can itself cause an overflow-like loss of data if significant bits are shifted out), and vacated positions are filled with 0. Always shift by exactly the number of places stated in the question, a common error is shifting the wrong number of places.
Binary shiftsShift left by 2Each place left multiplies by 2, so ×400000011= 3↓00001100= 12Bits pushed off the left are lost.Zeros are shifted in at the right.Shift right by 1Each place right divides by 200000011= 3↓00000001= 1The 1 pushed off the right is lost,so 3 ÷ 2 rounds down to 1.

Character sets

Computers store text by giving every character (letter, number, symbol) a unique binary code, using a character set. ASCII is a common character set that uses 8 bits per character in this course, giving 256 possible codes. Unicode is a newer character set that uses more bits per character, allowing it to represent far more characters, including emoji and characters from many different languages. Character sets are logically ordered, which means the code for 'B' is exactly one more than the code for 'A', and 'C' is one more than 'B'.
A character set assigns a unique binary code to every character. ASCII uses 8 bits per character (in this course), giving 256 possible characters, enough for English letters, digits and symbols, but not enough for every language's alphabet. Unicode uses more bits per character, so it can represent a much larger range of characters, covering many world languages and emoji, at the cost of larger file sizes. Character sets are logically ordered, so the code for 'B' is one more than the code for 'A', which makes letters straightforward to compare and sort.
Character sets are logically ordered, so the code for 'B' is exactly one more than the code for 'A', which makes tasks like comparing or sorting letters straightforward. The number of characters a set can represent is fixed by how many bits are used per character (n bits gives 2n possible codes), which is exactly why ASCII (8 bits, 256 codes) cannot represent as many characters as Unicode. You are not required to memorise specific character codes.

Representing images

A digital image is made up of a grid of tiny dots called pixels, each pixel's colour is stored as a binary code. Increasing the colour depth (bits per pixel) allows more possible colours per pixel, improving image quality but increasing file size. Increasing the resolution (number of pixels) makes the image sharper but also increases file size. Images also store metadata, extra information such as the image's height and width.
An image is stored as a grid of pixels, each with a colour represented by a binary code. Colour depth (bits per pixel) determines how many different colours each pixel can show, more bits means more possible colours and better quality, but a larger file. Resolution (the number of pixels, e.g. width × height) affects how sharp and detailed the image looks, again trading quality against file size. Metadata is extra information stored alongside the pixel data, such as the image's dimensions.
Each pixel's colour is encoded using a fixed number of bits (the colour depth); increasing colour depth increases the number of representable colours (2bits) and therefore image fidelity, at a directly proportional cost in file size (recall: image file size = colour depth × height × width). Increasing resolution increases the total pixel count, improving sharpness but also increasing file size. Metadata (e.g. dimensions, colour depth, creation date) is stored alongside the pixel data to allow the image to be correctly reconstructed and displayed.
An image = a grid of pixelsEach pixel = a binary colour codeColour depth ↑ = more colours per pixelResolution ↑ = more pixels, sharper image

Representing sound

Sound in the real world is an analogue (continuously varying) wave, but computers can only store digital data. To convert sound into digital form, the wave's amplitude (height) is measured, or sampled, at regular intervals and each sample is stored as a binary number. The sample rate (measured in Hertz, Hz) is how many samples are taken per second, the bit depth is how many bits are used to store each sample, and the duration is the length of the recording in seconds.
Analogue sound must be converted to digital by sampling: measuring the amplitude of the sound wave at regular intervals and storing each measurement as a binary number. Increasing the sample rate (Hz, samples per second) captures the wave more accurately; increasing the bit depth (bits per sample) allows more precise amplitude values. Both improve playback quality but increase file size (recall: sound file size = sample rate × duration × bit depth).
Digital audio sampling measures and stores the amplitude of the analogue wave at fixed intervals, not the frequency, a common exam error is describing frequency (pitch) as what's being sampled rather than amplitude. Higher sample rate and bit depth both increase fidelity to the original analogue wave and increase file size proportionally; duration simply scales the total file size linearly with recording length.
The same sound, sampled twiceLow sample rateFewer measurements per second, less accurateHigh sample rateMore measurements per second, closer to the originalEach sample stores the amplitude as a binary number

Exam Phrasing: Use These Exact Phrases

  • ✓An 8-bit binary number can represent denary values from 0 to 255
  • ✓Overflow occurs when the result of a calculation needs more bits than are available to store it
  • ✓Each hexadecimal digit represents exactly 4 bits (one nibble)
  • ✓A left shift multiplies the number by 2 for each place shifted; a right shift divides it by 2
  • ✓A character set assigns a unique binary code to each character
  • ✓Colour depth is the number of bits used to represent the colour of one pixel
  • ✓Sampling measures and stores the amplitude of a sound wave at regular intervals
  • 💡For 8-bit numbers, remember the range is 0 to 255, not 256, a very common exam slip.
  • 💡Show every step of a conversion or calculation clearly, including carries in binary addition, examiners award marks for correct working.
  • 💡If you change your mind, cross the answer out clearly and rewrite it. Overwriting a 1 into a 0 (or the reverse) is a real cause of lost marks, examiners cannot tell which digit you meant and award nothing.
  • 💡When answering a binary shift question, double-check you have shifted by exactly the number of places stated.
  • 💡For sound sampling questions, remember it is amplitude that is measured, not frequency.
  • 💡Don't try to memorise ASCII codes, you are not required to know them, only how character sets work.

Wrong:

The largest 8-bit binary number represents 256 in denary

Right:

The largest 8-bit binary number (11111111) represents 255

Why it matters: An 8-bit number has 256 possible values, but because it starts at 0, the range is 0-255, not 1-256.

Wrong:

Converting binary numbers to denary, adding them, then converting back counts as binary addition

Right:

Binary addition should be carried out directly in binary, showing carries

Why it matters: OCR examiners noted this method can produce the correct final answer but does not earn the marks awarded for showing correct binary working.

Wrong:

Increasing the bit depth means more samples are taken per second

Right:

Increasing the bit depth means a wider range of amplitude values can be stored for each sample; it is the sample rate that controls how many samples are taken per second

Why it matters: OCR examiners are explicit that credit needs "a wider range of amplitudes can be recorded", and specifically not "more amplitudes or samples per second".

Wrong:

Sound sampling measures the frequency of the wave

Right:

Sound sampling measures the amplitude of the wave at set intervals

Why it matters: Frequency relates to pitch, not what is measured during sampling, this is a common mix-up flagged by examiners.

Wrong:

Shifting by the wrong number of places on a binary shift question

Right:

Always shift by exactly the number of places stated in the question

Why it matters: Examiners noted candidates often shifted digits accurately but by an incorrect number of places.

Wrong:

Increasing colour depth increases an image's resolution

Right:

Colour depth (bits per pixel) and resolution (number of pixels) are separate properties

Why it matters: OCR examiners flagged this as a common misconception, increasing colour depth increases the number of possible colours, not the number of pixels.

Question:

Convert the denary number 45 into an 8-bit binary number. [2]

💡 Attempt this before revealing the answer, practice makes perfect!

Model Answer:

45 = 32 + 8 + 4 + 1, so the binary number is 00101101.

Mark Scheme:

  • 1Correct method: breaking 45 down into place values that sum to it (128, 64, 32, 16, 8, 4, 2, 1)
  • 2Correct final 8-bit answer: 00101101

Convert an 8-bit binary number to denary.

Loading a question…

Questions are generated fresh every time, so you can keep practising as long as you want.

Tap a card to flip it. Use the arrow keys to move and space to flip.

Known 0 Still learning 0
1 / 16

Exam-style questions. Have a go, then reveal the mark scheme to check your answer.

1.State the denary value represented by the 8-bit binary number 00000000.

[1]

2.Convert the denary number 200 into an 8-bit binary number.

[2]

3.Convert the hexadecimal number A0 into denary.

[2]

4.Add the binary numbers 00010110 and 00001101, showing your working. Explain whether an overflow error occurs.

[3]

5.Explain why increasing the colour depth of an image improves its quality but also increases its file size.

[3]

6.The binary number 00000110 is shifted left by 2 places. State the result and its denary value, and explain the effect the shift has had.

[3]

7.A character set uses 8 bits per character. Explain why it can represent 256 different characters, and why Unicode can represent more.

[3]

8.Explain how an analogue sound is converted into a digital file, and state the effect of increasing the sample rate.

[4]

9.Discuss why computers store all data in binary, and explain why programmers often work in hexadecimal instead.

[8]

Extended response · marked in levels, not by counting points

The examiners' reports are the most useful and least read of the three: they say what candidates actually got wrong each year. All files are hosted by OCR.

Past-paper questions grouped by topic

The same OCR questions, sorted by topic rather than by year (via Physics & Maths Tutor).

2024
Paper 1

On a question about the range of values an 8-bit binary number can store, common errors included giving 1 instead of 0 as the smallest value, and giving 256 (or the 7-bit maximum of 127) instead of 255 as the largest value.

Paper 1

On a binary shift question, most candidates shifted the digits accurately, but some shifted by the wrong number of places, for example moving 3 places when a different number was required.

Paper 1

On a hex-to-denary conversion question, stronger answers clearly annotated each step of their working. Candidates who chose straightforward hex values (like A0) tended to convert more accurately than those who chose more complex values.

Paper 1

On a binary addition question, most candidates showed their carries and scored well. Some candidates converted both binary numbers to denary, added them, then converted back, this can give the correct final answer but does not earn the marks for showing binary working.

Paper 1

On a sound sampling question, candidates who correctly identified that amplitude is measured at set intervals did well. A common error was stating that frequency is measured instead.

2023
Paper 1

On a question about the effect of increasing colour depth, most candidates correctly identified that file size increases and more colours become available. A common misconception was that increasing colour depth increases the image's resolution, when resolution is actually about the number of pixels, not the number of bits used per pixel.