Skip to content

0478 · Unit 1 · Paper 1: Computer systems

Data representation.

0478 · Unit 1 · Data representation
Revisionbyexamplicity

Binary and denary

§1.1 · Number systems

Inside a computer, everything is built from switches that are either off or on. So all data (numbers, text, images, sound and program instructions) is converted to binary, where each bit is 0 or 1, so that logic gates can process it and registers can store it.

Three number systems

Binary, denary and hexadecimal write the same value in different ways. Learn each one’s digits and place values: every conversion uses them.

Denary · base 10

Digits 0–9; each place is worth ×10.

1000 · 100 · 10 · 1

Binary · base 2

Digits 0 and 1; each place is worth ×2.

… 16 · 8 · 4 · 2 · 1

Hexadecimal · base 16

Digits 0–9, then A–F = 10–15; ×16.

4096 · 256 · 16 · 1

Convert between binary and denary

Both directions use the same row of place values. Write it above the bits first, then add or subtract.

Binary → denary

Add the place values that hold a 1.

128164032116080412011
128 + 32 + 4 + 1 = 165

Denary → binary

Subtract the largest place value that fits and write 1; otherwise write 0.

128164032116180412110
182 − 128 = 5454 − 32 − 16 = 66 − 4 − 2 = 0182 = 101101108 bits

How many values can n bits hold?

Each extra bit doubles the number of patterns. Read across a row to find what a register of that size can hold.

RegisterDifferent valuesDenary rangeLargest in hex
4 bits160 to 15F
8 bits2560 to 255FF
12 bits4 0960 to 4 095FFF
16 bits65 5360 to 65 535FFFF

Why 2ⁿ − 1?

n bits make 2ⁿ different patterns. One of them is 0, so the largest value is 2ⁿ − 1.

12 bits: 2¹² = 4096 patterns, so the largest value is 4095 (hex FFF).

Your turn

1 Convert 01001101 to denary.

2 Convert 90 to 8-bit binary.

3 What is the largest denary value that 6 bits can hold?

  1. 1
    64 + 8 + 4 + 1 = 77
  2. 2
    64 + 16 + 8 + 2, so 01011010
  3. 3
    2⁶ − 1 = 63
Tick what you can do now
Exam focusWrite the place values above the bits and show the subtraction or addition. An 8-bit answer has exactly 8 digits, so keep the leading zeros: 22 is 00010110.
Practise with m26/12 Q6(a); s26/13 Q8(b); w25/12 Q1(a)–(b) (older paper)
1 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Hexadecimal

§1.1 · Number systems

A long row of 0s and 1s is hard for a person to read or copy without a slip. Hexadecimal (base 16) shortens it: one hex digit stands for exactly four bits. It uses sixteen digits, 0–9 and then A–F for 10–15.

Conversion strip: 0 to F

Find a hex digit in the top row, then read its four bits and its denary value underneath.

Hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Denary
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
HexBinaryDenary
000000
100011
200102
300113
401004
501015
601106
701117
HexBinaryDenary
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115

Convert in groups of four bits

Four bits make exactly one hex digit, so binary and hex swap group by group. Denary needs place values of 16 instead.

Binary ↔ hexadecimal

Group bits in fours from the right. Keep four bits for each hexadecimal digit.

0110 1001 1100 → 6 9 Cone digit per group69Chexadecimal29D → 0010 1001 1101hexadecimal → binary

Hexadecimal ↔ denary

Multiply each digit by its place value. To go back, divide by 16 and keep the remainder.

2E7 = 2 × 256 + 14 × 16 + 7= 743denary219 ÷ 16 = 13 remainder 1113 is D; 11 is B219 = DBhexadecimal

Hexadecimal in use

Give two reasons people use it, and name where it is seen.

Why use hexadecimal?

  • Shorter: one hex digit replaces four bits, so it takes less space on screen.
  • Easier for people to read, write and remember, with fewer mistakes.
  • Easier to spot errors and debug.

Where you will see it

  • Memory addresses and memory dumps · error codes
  • MAC addresses and IPv6 addresses
  • HTML colour codes, e.g. #FF8000 · assembly code · URLs
Your turn

1 Convert 1011 0110 to hexadecimal.

2 Convert 3F to binary.

3 Convert A5 to denary.

  1. 1
    1011 is B and 0110 is 6, so B6
  2. 2
    0011 1111
  3. 3
    10 × 16 + 5 = 165
Tick what you can do now
Exam focusHexadecimal is a shorter way for people to write binary. The computer still stores the value in binary, so hex does not reduce the memory needed. Write every bit, including leading zeros.
Practise with s26/12 Q3(a)–(d)
2 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Binary addition, overflow and shifts

§1.1 · Number systems

Binary adds like denary, column by column, but you carry as soon as a column makes 2. A register has only so many bits, so an answer can be too big to fit. A logical shift moves every bit left or right.

Add binary from right to left

Start at the right-hand column and carry 1 whenever a column adds up to 2 or more. Watch what the second sum does to the 9th bit.

Rules

0 + 0 = 0
write 0
0 + 1 = 1
write 1
1 + 1 = 10
write 0, carry 1
1 + 1 + 1 = 11
write 1, carry 1

25 + 67 = 92

11
00011001
+01000011
01011100

Result 01011100 = 64 + 16 + 8 + 4 = 92. It fits in 8 bits.

200 + 100: overflow

1
11001000
+01100100
100101100
  • An 8-bit register holds 0 to 255.
  • 300 needs a 9th bit (256), which has nowhere to go: overflow error.
  • The 8 bits left show 44.

An 8-bit register holds 0 to 255. 300 needs a 9th bit (256), which has nowhere to go: overflow error. The 8 bits left show 44.

Logical shifts

Every bit moves the same number of places. Bits shifted off the end are lost; 0s fill the empty places.

Logical shift left 1 place

beforeafter= 440001011000101100lost00 in= 8844 → 88: × 2

The most significant bit (left-most) is lost; a 0 enters as the least significant bit.

Logical shift right 1 place

beforeafter= 450010110110010110lost00 in= 2245 → 22: ÷ 2, remainder lost

The least significant bit (right-most) is lost; a 0 enters as the most significant bit.

Shifting more than one place

Each place left doubles the value and each place right halves it, until a 1 falls off the end.

ShiftBeforeAfterEffect
Left 200010110 (22)01011000 (88)× 4 = 88
Right 200010110 (22)00000101 (5)÷ 4 = 5.5 → 5 (remainder lost)
Left 300101100 (44)01100000 (96)should be 352, but a 1 was lost: result 96
Your turn

1 Add 00110101 and 00011011.

2 Add 10010110 and 01111000 in an 8-bit register. What goes wrong?

3 Shift 00010110 two places left. What is the result in denary?

  1. 1
    01010000 (53 + 27 = 80)
  2. 2
    150 + 120 = 270 needs a 9th bit, so there is an overflow error; the 8 bits left are 00001110
  3. 3
    01011000 = 88, which is 22 × 4
Tick what you can do now
Exam focusShow your carries and write the overflow bit when there is one. When describing a shift, say which bit is lost (most or least significant) and that 0s are added.
Practise with m26/12 Q6(c), (e); s26/11 Q3(f); w25/12 Q2(b) (older paper)
3 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Two’s complement and character sets

§1.1 · §1.2 · Signed integers and text

A bank balance can drop below zero and a message is made of letters, yet a register holds only 0s and 1s. Both problems are solved the same way: agree a code, so the same bits can stand for a negative number or a character.

Two’s complement: 8-bit signed integers

Binary has no minus sign, so negative numbers need a code of their own. In 8-bit two’s complement, the left-most bit is worth −128 instead of +128.

In 8-bit two’s complement the left-most bit is worth −128 instead of +128. Every other place value stays the same.

Denary → two’s complement (negative)

1 Write +35001000112 Invert every bit110111003 Add 111011101
  • Positive numbers are written as normal binary, always with a leading 0.
  • 8 bits cover −128 (10000000) to +127 (01111111).

Two’s complement → denary

−128164132016181412011
−128 + 64 + 16 + 8 + 4 + 1 = −35

Method 1: the most significant bit is worth −128; add the place values holding a 1.

Method 2: if the MSB is 1, invert and add 1 to find the size: 00100010 + 1 = 00100011 = 35, so the value is −35.

Text: a character set gives each character a unique code

Text is stored as the code of each character, one after another in the same order: “fox” → 102, 111, 120. Within the lower-case alphabet, codes are consecutive: if f = 102, then h = 102 + 2 = 104.

f
code 102
01100110
o
code 111
01101111
x
code 120
01111000

ASCII and Unicode

Compare them on bits per character, the range of characters and storage space.

ASCII

  • Uses 7-bit codes for 128 characters; extended ASCII uses 8-bit codes, up to 256 characters.
  • Enough for English letters, digits, punctuation and control codes.
  • Upper and lower case have different codes: A = 65, a = 97.

Unicode

  • Can use more bits per character than ASCII.
  • Represents a far greater range of characters: many languages, symbols and emojis.
  • Characters needing more bits take more storage space.
Your turn

1 Write −20 in 8-bit two’s complement.

2 What denary value is 11110110 in two’s complement?

3 The code for A is 65. What is the code for D?

  1. 1
    +20 is 00010100; invert and add 1: 11101100
  2. 2
    −128 + 64 + 32 + 16 + 4 + 2 = −10
  3. 3
    68
Tick what you can do now
Exam focusNever put a minus sign in front of binary, and do not just change the first bit. For −35: write +35, invert, add 1. Write all 8 bits; 8-bit two’s complement covers −128 to +127.
Practise with s26/13 Q8(d); s26/12 Q1(c); s26/13 Q1(c)(i)–(ii); s26/11 Q8(a); w24/13 Q2(d) (older paper)
4 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Images

§1.2 · §1.3 · Representing images and their file size

Zoom far enough into a photo on a screen and it breaks up into tiny squares. Each square is a pixel, and the image is stored as a grid of them: the colour of each pixel is a binary number.

Four terms to define

Define each in one sentence, using the words in bold.

Pixel

The smallest component of an image. An image is broken down into pixels; each pixel’s colour is stored as a binary value.

Resolution

The number of pixels in the image: width × height.

Colour depth

The number of bits used for each pixel’s colour.

Metadata

Extra data stored with the image, e.g. width, height, colour depth, date taken.

Each row of the icon is stored as one binary number. Add one bit of colour depth and the number of colours doubles.

8 × 8 = 64 pixels · 1 bit per pixel00011000001111000111111011111111010000100101101001011010011111101 = dark · 0 = light · each row is stored in orderColour depth = bits per pixel1 bit2 colours2 bits4 colours3 bits8 coloursn bits → 2ⁿ colours8 bits → 256 · 24 bits → 16 777 216 colours
8 × 8 = 64 pixels00011000001111000111111011111111010000100101101001011010011111101 bit per pixel: 1 = dark, 0 = lightColour depth = bits per pixel1 bit2 colours2 bits4 colours3 bits8 coloursn bits → 2ⁿ colours · 8 bits → 256 · 24 bits → 16 777 216
8 × 8 = 64 pixels · 1 bit per pixel1 = dark · 0 = lightEach row is stored in the same order:1: 000110005: 010000102: 001111006: 010110103: 011111107: 010110104: 111111118: 01111110Colour depth: n bits → 2ⁿ colours1 bit2 colours2 bits4 colours3 bits8 colours8 bits → 256 · 24 bits → 16 777 216 colours

Change a setting

Say what happens to the image and to the file size.

Increase the resolution

More pixels → more detail and a sharper image, but a larger file.

Increase the colour depth

More bits per pixel → more colours, more accurate shades, and a larger file.

Image file size

Multiply the three settings to get bits, then divide down to the unit the question asks for.

Worked example

128 × 256 pixels · colour depth 8 bits
width × height × colour depth
128 × 256 × 8= 262 144 bits÷ 8 = 32 768 bytesbits → bytes÷ 1024 = 32 KiBbytes → KiB

Bits, then bytes

The formula gives bits. Divide by 8 for bytes, then by 1024 for each larger unit (KiB, MiB, …).

262 144 bits÷ 88 bits in a byte32 768 bytes÷ 10241024 bytes in a KiB32 KiB
Your turn

1 An image is 64 × 32 pixels with a colour depth of 4 bits. Find its size in bits.

2 Give that size in KiB.

3 The colour depth is doubled to 8 bits. What happens to the file size?

  1. 1
    64 × 32 × 4 = 8192 bits
  2. 2
    8192 ÷ 8 = 1024 bytes = 1 KiB
  3. 3
    It doubles to 2 KiB: every pixel now needs twice as many bits
Tick what you can do now
Exam focusColour depth is the bits per pixel, which sets how many colours can be represented; not “the number of colours in the image”. “The image has pixels” is not enough: say it is broken down into pixels and each pixel’s colour is stored as a binary value.
Practise with s26/11 Q8(b)(i); s26/12 Q6(a); m26/12 Q1(b)
5 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Sound

§1.2 · §1.3 · Representing sound and its file size

A sound wave changes smoothly, but a computer can only store numbers. So the wave is sampled: its amplitude is measured at regular time intervals, each sample is converted to a binary value, and the values are stored in sequence.

A sound wave changes smoothly, but a computer can only store a list of numbers. So the wave is sampled and stored in three steps.

  1. 1
    Its amplitude is measured at regular time intervals.
  2. 2
    Each sample is converted to a binary value.
  3. 3
    The values are stored in sequence.

Blue dots show stored samples of the same wave. Change one setting at a time to see its effect.

Sampling a sound wave: 8 samples · 2 bits0001101110101010010001108 × 2 = 16 bitsorange: played backHigher sample rate: 16 × 2 = 32 bits0001101110101010101010100101000001011010Higher sample resolution: 8 × 3 = 24 bits000001010011100101110111110101100101011001010100
Sampling a sound wave: 8 samples · 2 bits0001101110101010010001108 × 2 = 16 bitsorange: played backHigher sample rate: 16 × 2 = 32 bits0001101110101010101010100101000001011010Higher sample resolution: 8 × 3 = 24 bits000001010011100101110111110101100101011001010100
Sampling a sound wave: 8 samples · 2 bits0001101110101010010001108 × 2 = 16 bitsorange: played backHigher sample rate: 16 × 2 = 32 bits0001101110101010101010100101000001011010Higher sample resolution: 8 × 3 = 24 bits000001010011100101110111110101100101011001010100

Two settings

Define each one and say what increasing it does.

SettingMeaningIncrease it and…
Sample rateNumber of samples taken per second (hertz, Hz)more of the wave is captured: a more accurate recording, but a larger file
Sample resolutionNumber of bits per samplemore amplitude levels (n bits → 2ⁿ levels): each sample is more precise, but the file is larger

Sound file size

The file holds every sample’s bits: sample rate × resolution × seconds. Put each value into the right unit before you multiply.

Worked example

sample rate 8 kHz · resolution 16 bits · 10 seconds
sample rate × resolution × seconds
8000 × 16 × 108 kHz = 8000 Hz= 1 280 000 bits÷ 8 = 160 000 bytesbits → bytes÷ 1024 = 156.25 KiBbytes → KiB
If the question gives…Do this first
Sample rate in kHz× 1000 (not 1024: frequency is not storage): 44.1 kHz = 44 100 Hz
Length in minutesConvert to seconds: 3 minutes = 180 s
Several tracksFind one file’s size, then multiply by the number of files
Your turn

1 A sound is recorded for 4 seconds at 2 kHz with a sample resolution of 8 bits. Find its size in bits.

2 Give that size in bytes.

3 The sample rate is increased. Give two effects.

  1. 1
    2000 × 8 × 4 = 64000 bits
  2. 2
    64000 ÷ 8 = 8000 bytes
  3. 3
    The recording is more accurate, and the file is larger
Tick what you can do now
Exam focusSample resolution is the bits per sample, not the number of samples. Describe the process in order: amplitude measured at set intervals, each sample converted to binary, values stored.
Practise with s26/13 Q3(b); s26/11 Q8(b)(i); w24/12 Q2(c) (older paper)
6 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Measuring data storage

§1.3 · Data storage and compression

A text message takes a few bytes; a film takes billions. Sizes that far apart are counted in bits, bytes and much larger units. From the kibibyte up, each unit is 1024 times the one before.

Storage units, in order of size

The number by each arrow is how many of the smaller unit make the next one up.

bit1 or 0×4nibble4 bits×2byte8 bits×1024KiBkibibyte×1024MiBmebibyte×1024GiBgibibyte×1024TiBtebibyte×1024PiBpebibyte×1024EiBexbibyte
bit1 or 0× 4nibble4 bits× 2byte8 bits× 1024KiBkibibyte× 1024MiBmebibyte× 1024GiBgibibyte× 1024TiBtebibyte× 1024PiBpebibyte× 1024EiBexbibyte

1 nibble = 4 bits · 1 byte = 8 bits · 1 KiB = 1024 bytes · 1 MiB = 1024 KiB · and so on up to the exbibyte.

Convert step by step

Show each step and give the answer in the unit the question asks for.

Converting between units

2 PiB × 1024 = 2048 TiBdown a unit: × 10243072 KiB ÷ 1024 = 3 MiBup a unit: ÷ 10241 MiB ÷ 32 KiB = 3232 KiB files that fit in 1 MiB

Several files · answer in MiB

20 images · 1024 × 512 pixels · 24-bit colour
1024 × 512 × 24one image, bits= 12 582 912 bits÷ 8 ÷ 1024 ÷ 1024 = 1.5 MiBone image× 20 = 30 MiBall 20 images
These formulas give the size of the uncompressed data. A file may also store metadata in a header (e.g. image width, height, colour depth, date taken). Only add it when the question tells you its size.

Too big? Compress it

When a file is too big to store or send easily, compression reduces its size.

Why compress a file?

  • Less storage space is needed.
  • Shorter transmission time: faster to upload, download or stream.
  • Less bandwidth is used, e.g. on a limited data plan.
  • Fits within limits such as an email attachment size.
Your turn

1 How many KiB are there in 3 MiB?

2 Convert 16 384 bits to KiB.

3 Give two reasons to compress a file.

  1. 1
    3 × 1024 = 3072 KiB
  2. 2
    16 384 ÷ 8 = 2048 bytes; ÷ 1024 = 2 KiB
  3. 3
    Two from: less storage space, faster to send, less bandwidth used
Tick what you can do now
Exam focusBits and bytes are different units. Divide by 8 once to reach bytes, then by 1024 for each larger unit. Give the answer in the unit the question asks for, and show every step.
Practise with m26/12 Q1
7 / 8
0478 · Unit 1 · Data representation
Revisionbyexamplicity

Compression

§1.3 · Data storage and compression

Compression makes a file smaller by writing the same data more briefly, or by throwing some away. Lossless keeps every bit of the data; lossy removes some of it for good.

A phone photo can be too big to email or stream comfortably. Compression makes a file smaller by writing the same data more briefly, or by throwing some away. Lossless keeps every bit of the data; lossy removes some of it for good.

Lossless

No data is permanently removed. Decompression rebuilds the exact original file.

Use when every detail matters: text, program code, spreadsheets, a photo for professional printing.

Lossy

Data is permanently removed. The original cannot be rebuilt exactly.

Gives a much smaller file; often unnoticeable for photos, music and video.

Lossless: run-length encoding (RLE)

RLE finds runs of consecutive, identical data and stores each run once, as a count and a value.

16 pixels, read left to right (1 = dark, 0 = light)(4, 1)(3, 0)(2, 1)(6, 0)(1, 1)16 values stored as 5 pairs of (count, value).
4×13×02×16×01×1Count × value, in the original orderCounts add to 16: no pixel is discarded
  • Text works the same way: AAAABBBCCD → 4A 3B 2C 1D.
  • To decode (3, 0), repeat the value three times: write 000.
  • RLE only helps when the data has long runs; with few repeats the file can get bigger.
Text works the same way: AAAABBBCCD → 4A 3B 2C 1D. RLE only helps when the data has long runs; with few repeats the file can get bigger. To decode (3, 0), write 000: repeat the value three times.

Lossy methods

Name a method for an image or for sound, and say what it removes.

Lossy methods for images

original8 × 8 · 2 bitsresolution ↓4 × 4 · 2 bitscolour depth ↓8 × 8 · 1 bit
  • Reduce the resolution (the number of pixels).
  • Reduce the colour depth (fewer bits per pixel).
  • Merge similar colours that the eye cannot easily tell apart.

Lossy methods for sound

original16 samples · 3 bitssample rate ↓6 samples · 3 bitsresolution ↓16 samples · 1 bit
  • Reduce the sample rate or sample resolution.
  • Remove sounds people cannot hear, e.g. quiet sounds masked by louder ones.

Choose a method

Choose lossy or lossless, then link the reason to the scenario.

ScenarioChooseLinked reason
Emailing a written reportLosslessevery character must be kept, so the meaning is unchanged
Streaming video on a limited data planLossya much smaller file uses less data and buffers less
Sending a photo for a large printed posterLosslessno detail is lost, so the print stays sharp
Your turn

1 Encode WWWWWBBW with run-length encoding.

2 Decode 2A 4B 1C.

3 A program file must be compressed. Lossy or lossless? Why?

  1. 1
    5W 2B 1W
  2. 2
    AABBBBC
  3. 3
    Lossless: every character must come back exactly, or the program will not run
Tick what you can do now
Exam focusLink your choice to the scenario: “lossy, because a smaller file streams faster”. For RLE, name the repeated data (consecutive pixels, samples or characters); “repeating data/patterns” alone is too vague. MP4 and ZIP are file formats, not methods.
Practise with s26/12 Q3(g); s26/13 Q1(c)(iii); s26/11 Q8(b)(ii)
8 / 8