What you'll learn
Everything a computer stores is held as binary. In OCR GCSE Computer Science (J277, section 1.2, data storage) you must know how numbers, characters, images and sound are represented, how to convert between denary, binary and hexadecimal, how to add binary numbers and recognise overflow, how binary shifts work, how character sets such as ASCII and Unicode are used, how image and sound file sizes are calculated and what affects quality, and the purpose and types of compression. This guide covers each area with step-by-step methods and worked calculations.
This topic contains some of the most reliable marks in Paper 1, because the methods are fixed. The commonest errors are careless place values, forgetting to convert bits to bytes, and not showing working.
Key terms and definitions
Bit — A binary digit, 0 or 1.
Nibble — 4 bits. Byte — 8 bits.
Denary — Base 10. Binary — Base 2. Hexadecimal — Base 16, using 0–9 and A–F.
Overflow — An error that occurs when the result of a calculation needs more bits than are available.
Binary shift — Moving all bits left or right; a left shift multiplies, a right shift divides.
Character set — A defined list of characters, each represented by a unique binary code.
ASCII — A character set using 7 bits (128 characters), often stored as 8 bits.
Unicode — A character set that uses more bits per character to represent characters from many languages.
Pixel — The smallest element of a bitmap image.
Colour depth — The number of bits used to represent the colour of each pixel.
Resolution — The number of pixels in an image (width × height).
Metadata — Data about a file, such as an image's width, height and colour depth.
Sample rate — The number of sound samples taken per second (Hz).
Bit depth — The number of bits used to store each sound sample.
Lossy / lossless compression — Compression that permanently removes data / that allows the original to be fully restored.
Core concepts
Units
OCR uses: bit, nibble (4 bits), byte (8 bits), kilobyte (1,000 bytes), megabyte (1,000 KB), gigabyte (1,000 MB), terabyte (1,000 GB) and petabyte (1,000 TB). You may use 1,024 instead, as long as you are consistent.
Converting binary and denary
The 8-bit place values are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
Binary to denary: add the place values where there is a 1. 01101001 = 64 + 32 + 8 + 1 = 105.
Denary to binary: subtract the largest place value that fits, and repeat. 200 = 128 + 64 + 8 → 11001000.
With 8 bits, the range is 0 to 255.
Hexadecimal
Hex digits are 0–9 then A (10), B (11), C (12), D (13), E (14), F (15). One hex digit represents one nibble, so two hex digits represent one byte.
- Binary to hex: split into nibbles. 10101111 → 1010 | 1111 → AF.
- Hex to binary: convert each digit to 4 bits. 3C → 0011 | 1100 → 00111100.
- Hex to denary: first digit × 16 + second digit. 7E = 7 × 16 + 14 = 126.
- Denary to hex: divide by 16 for the first digit, remainder for the second. 200 ÷ 16 = 12 remainder 8 → C8.
Hex is used because it is shorter and easier for people to read and remember than binary, with fewer copying errors, while converting easily to and from binary. It is used for colour codes, MAC addresses and error codes.
Binary addition and overflow
Rules: 0 + 0 = 0; 0 + 1 = 1; 1 + 1 = 0 carry 1; 1 + 1 + 1 = 1 carry 1. Add from right to left.
Example: 01011010 + 00110111
01011010 (90)
+ 00110111 (55)
--------
10010001 (145)
If adding two 8-bit numbers produces a ninth bit, overflow occurs: the result is too large for the space available, so the extra bit is lost and the stored answer is wrong.
Binary shifts
A left shift of one place multiplies an unsigned binary number by 2; two places multiply by 4; three by 8. A right shift of one place divides by 2, two places by 4. Bits shifted off the end are lost and zeros fill the empty places, so a right shift of an odd number loses the remainder, and a left shift can cause overflow.
00010110 (22) shifted left 2 places → 01011000 (88).
Characters
Each character is given a binary code in a character set. Codes are sequential: if 'A' is 65, 'B' is 66 and so on, which lets programs sort text and convert case. ASCII uses 7 bits for 128 characters — English letters, digits, punctuation and control characters. Unicode uses more bits (commonly 16 or 32), so it can represent characters from almost every language, plus symbols and emoji; its first codes match ASCII. More bits per character means larger text files.
Images
A bitmap image is a grid of pixels. Each pixel's colour is stored in binary using a set number of bits — the colour depth. With colour depth n, there are 2ⁿ possible colours: 1 bit → 2 colours, 4 bits → 16, 8 bits → 256, 24 bits → about 16.7 million.
File size (bits) = width × height × colour depth.
Increasing resolution or colour depth improves image quality but increases file size. Metadata such as width, height and colour depth is stored with the image so it can be displayed correctly.
Sound
Sound is an analogue wave. To store it, its amplitude is measured (sampled) at regular intervals and each measurement is stored in binary.
- A higher sample rate (samples per second) captures the wave more accurately.
- A higher bit depth stores each sample more precisely.
- A longer duration needs more samples.
File size (bits) = sample rate × bit depth × duration (seconds).
Higher sample rate and bit depth give better quality but larger files.
Compression
Compression reduces file size, so files use less storage, transfer faster over networks and stream more smoothly.
Lossy compression permanently removes data considered less important, such as subtle colour variations or frequencies people cannot easily hear. It greatly reduces file size but the original cannot be restored, and quality falls if compressed too much. Examples: JPEG, MP3, MP4.
Lossless compression reduces file size without losing any data; the original can be restored exactly. It is essential for text documents, spreadsheets and program files, where losing a single character would cause problems. Compression is less dramatic than lossy. Examples: PNG, ZIP.
Why media files are compressed online
Uncompressed images and sound are very large. A single uncompressed photo from a modern phone camera can take many megabytes, and an uncompressed minute of CD-quality stereo sound takes about 10 MB. Websites, streaming services and messaging apps therefore compress media so that pages load quickly, videos stream without buffering and less mobile data is used. Choosing the right compression is a trade-off:
- Photographs on a website — lossy compression gives small files and the loss is barely visible.
- A logo or diagram with sharp edges and few colours — lossless compression keeps edges crisp.
- A text document or program — lossless only, because every character matters.
- Music streaming — lossy compression, with higher-quality settings offered for faster connections.
Checking your answers
Conversions can be checked by reversing them. If you convert 171 to AB, convert AB back: 10 × 16 + 11 = 171. If you add two binary numbers, convert all three to denary and check the sum. For file sizes, estimate first: an 800 × 600 image is about half a million pixels, so with 24-bit colour it should be roughly 1.4 million bytes. A wildly different answer signals a mistake with units.
Worked examples
Example 1: Image file size
An image is 100 × 50 pixels with a colour depth of 4 bits. Calculate the file size in bytes. (2 marks)
100 × 50 × 4 = 20,000 bits (1). 20,000 ÷ 8 = 2,500 bytes (1).
Example 2: Sound file size
A sound file is recorded for 10 seconds with a sample rate of 44,100 Hz and a bit depth of 16. Calculate the size in kilobytes.
44,100 × 16 × 10 = 7,056,000 bits. ÷ 8 = 882,000 bytes. ÷ 1,000 = 882 KB.
Example 3: Hex conversion
Convert the denary number 171 to hexadecimal.
171 ÷ 16 = 10 remainder 11. 10 = A, 11 = B. AB. (Check: 10 × 16 + 11 = 171.)
Example 4: Overflow
Explain what happens when 11110000 is added to 00100000 in an 8-bit register.
11110000 = 240 and 00100000 = 32. The total, 272, is greater than 255, so it needs nine bits. Overflow occurs: the ninth bit is lost, and the register stores 00010000 (16), which is incorrect.
Common mistakes and how to avoid them
- Not dividing by 8 when the answer is required in bytes.
- Confusing colour depth and resolution. Depth = bits per pixel; resolution = number of pixels.
- Reading hex letters as separate digits. F = 15, not "1 and 5".
- Forgetting that a right shift loses bits. 7 shifted right by 1 gives 3, not 3.5.
- Saying lossless compression "doesn't reduce file size". It does, just not as much as lossy.
- Leaving out working. Method marks are available.
Exam technique for "Data Representation"
- Write out the place value headings before every binary conversion.
- Lay out calculations one step per line, with units.
- When explaining quality vs file size, always mention both effects.
- For compression questions, match the type to the file: lossless for text and code, lossy for media where small size matters.
Quick revision summary
- Units: bit, nibble, byte, KB, MB, GB, TB, PB (×1,000, or ×1,024 consistently).
- Binary place values: 128 → 1; 8 bits store 0–255.
- Hex: one digit per nibble; used because it is shorter and easier to read.
- Binary addition can cause overflow; left shifts multiply, right shifts divide.
- ASCII 7-bit, Unicode more bits and more languages; codes are sequential.
- Image size = width × height × colour depth; sound size = sample rate × bit depth × seconds.
- Lossy compression removes data permanently; lossless restores it exactly.