Skip to content

Information representation

A-Level Computer Science · Topic 1

Train
1.1

Number systems

Syllabus
Candidates should be able to: Notes and guidance
Show understanding of binary magnitudes and the difference between binary prefixes and decimal prefixes Understand the difference between and use: • kibi and kilomebi and megagibi and gigatebi and tera
Show understanding of different number systems Use the binary, denary, hexadecimal number bases and Binary Coded Decimal (BCD) and one’s complement and two’s complement representation for binary numbers
Convert an integer value from one number base/ representation to another
Perform binary addition and subtraction Using positive and negative binary integers
Show understanding of how overflow can occur
Describe practical applications where Binary Coded Decimal (BCD) and Hexadecimal are used
Show understanding of and be able to represent character data in its internal binary form, depending on the character set used Students are expected to be familiar with ASCII (American Standard Code for Information Interchange), extended ASCII and Unicode. Students will not be expected to memorise any particular character codes

Source: Cambridge International syllabus

Counting in binary: 0 to 15

The three number systems 数制 you must use:

  • denary 十进制 (decimal, base 10) — uses digits 0–9. Place values are powers of ten.
  • binary 二进制 (base 2) — uses 0 and 1. Place values are powers of two. Every byte 字节 is 8 bits.
  • hexadecimal 十六进制 (base 16) — uses 0–9 then A–F for 10–15. Each hex digit 数位 stands for exactly 4 bits.

Beads on a traditional abacus An abacus represents numbers by place value — the same idea behind decimal, binary and hexadecimal

Conversions

Denary → binary: keep dividing by 2 and record the remainders, read bottom-up. Or subtract the largest place value 位值 (power of 2) that fits.

Example: $558_{10}$: $558 = 512 + 32 + 8 + 4 + 2 = 2^{9} + 2^{5} + 2^{3} + 2^{2} + 2^{1}$. In 12 bits: 0010 0010 1110.

Binary → hex: group the bits into nibbles 半字节 (4 bits) from the right and convert each. 0010 0010 11102 2 E22E.

Hex → binary: replace each hex digit with its 4-bit pattern. Hex → denary: multiply each digit by its place value. 22E $= 2 \times 256 + 2 \times 16 + 14 = 558$.

Worked example. Convert denary 200 to 8-bit binary, then to hexadecimal.

$200 = 128 + 64 + 8$, so the binary is 11001000. In nibbles, 1100 1000 $= 12$ and $8$, i.e. $\text{C}$ and $8$, so the hexadecimal is C8.

A binary place-value chart for 200: the columns 128, 64, 32, 16, 8, 4, 2, 1 hold the bits 1,1,0,0,1,0,0,0; the two 4-bit nibbles 1100 and 1000 become the hex digits C and 8, so 200 = 11001000 = C8 Reading 200 from its place values, then grouping the bits into nibbles to get hex C8

Binary vs decimal prefixes

Two prefix families look similar but differ — decimal (powers of 10) and binary (powers of 2):

Decimal (SI) Binary (memory)
kilo $= 10^{3}$ kibi (Ki) $= 2^{10} = 1024$
mega $= 10^{6}$ mebi (Mi) $= 2^{20}$
giga $= 10^{9}$ gibi (Gi) $= 2^{30}$
tera $= 10^{12}$ tebi (Ti) $= 2^{40}$

So a tebibyte (TiB) is slightly more than a terabyte (TB). A "1 TB" drive holds $10^{12}$ bytes, but an operating system that reports in TiB shows a smaller number.

Explore

Binary, denary and hex

Type a number and see it in binary, denary and hexadecimal at once — and how the place values add up.

Vocabulary Train
English Chinese Pinyin
number system 数制 shù zhì
denary 十进制 shí jìn zhì
binary 二进制 èr jìn zhì
byte 字节 zì jié
bit wèi
hexadecimal 十六进制 shí liù jìn zhì
digit 数位 shù wèi
place value 位值 wèi zhí
nibble 半字节 bàn zì jié
1.1

Binary arithmetic

Binary addition

Add column by column from the right, carrying as in denary:

Bit A Bit B Carry in Sum bit Carry out
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 1 0 0 1
1 1 1 1 1

Overflow 溢出 happens when the result needs more bits than the register 寄存器 can hold — the carry-out of the leftmost column is the overflow bit.

Binary subtraction

The usual way is two's complement 补码 addition: to do $A - B$, form the two's complement of $B$ (invert every bit and add 1), then add, and discard any final carry-out.

To subtract $00011110$ from $01100100$ (unsigned 8-bit):

  • two's complement of $00011110$: invert → $11100001$, add 1 → $11100010$.
  • add to $01100100$: result $1\,01000110$ (9 bits) — discard the leading 1 → $01000110 = 70_{10}$. Check: $100 - 30 = 70$. ✓

Two's complement signed integers

In an $n$-bit two's-complement number:

  • the most significant bit 最高有效位 (MSB) is the sign bit 符号位: 0 = positive, 1 = negative.
  • to read a negative number: invert every bit, add 1, then negate.

So $11100010$ is negative; invert → $00011101$, add 1 → $00011110 = 30$, so it is $-30$. This is a signed integer 有符号整数 (unlike an unsigned 无符号 one). The range for $n$ bits is $-2^{n-1}$ to $+2^{n-1} - 1$; for 8 bits, $-128$ ($10000000$) to $+127$ ($01111111$).

An 8-bit two's-complement number line from -128 (10000000) to +127 (01111111); numbers with sign bit 1 are negative and those with sign bit 0 are positive, with -1 = 11111111 sitting just below 0 = 00000000 8-bit two's complement: the sign bit splits the range into negative ($-128$ to $-1$) and positive ($0$ to $127$)

Worked example. What denary value does the 8-bit two's-complement number $10110100$ represent?

The MSB is 1, so it is negative. Invert → $01001011$, add 1 → $01001100 = 76$, so the value is $-76$. Check with place values: $-128 + 32 + 16 + 4 = -76$.

Overflow in signed arithmetic happens when the true result falls outside this range — spotted when the sign bit flips wrongly (two positives giving a negative, or two negatives giving a positive).

One's complement

Before two's complement, an older scheme called one's complement 反码 represented a negative number by simply inverting every bit of the positive — there is no "add 1" step.

  • $+30 = 00011110$, so in one's complement $-30 = 11100001$ (just the inverse).
  • Drawback: it has two zeros$00000000$ ($+0$) and $11111111$ ($-0$) — which wastes a bit pattern and makes arithmetic awkward.

Two's complement (invert and add 1) removes the negative zero: it has a single zero and lets addition and subtraction use the same circuit. That is why modern computers store signed integers in two's complement, not one's complement.

Explore

Binary & signed integers

byte = Σ place values

See how an 8-bit pattern maps to a number (and how it would overflow past 255).

Explore

Two's complement signed bits

The leftmost bit carries a negative place value. Flip any bit — or hit Negate (invert every bit, then add 1) — and watch the signed value change.

Vocabulary Train
English Chinese Pinyin
overflow 溢出 yì chū
register 寄存器 jì cún qì
two's complement 补码 bǔ mǎ
most significant bit 最高有效位 zuì gāo yǒu xiào wèi
sign bit 符号位 fú hào wèi
signed integer 有符号整数 yǒu fú hào zhěng shù
unsigned 无符号 wú fú hào
one's complement 反码 fǎn mǎ
1.1

Binary Coded Decimal (BCD)

In BCD 二进码十进数, each denary digit is written as its own 4-bit pattern. The number $93$ is 1001 0011 in BCD — not binary 93 ($01011101$). Each nibble uses only 0–9; patterns $1010$$1111$ are invalid.

BCD reading: 0010 0111 0101 → 2, 7, 5 → 275.

Use: calculators, digital clocks, and devices that show denary digits — each digit drives a 7-segment display 七段显示器. Currency code often uses BCD to avoid the rounding errors of converting fractions like 0.1 to binary.

A single-digit seven-segment LED display component, showing its seven separate bars A seven-segment display shows one denary digit, often driven by BCD

Vocabulary Train
English Chinese Pinyin
BCD 二进码十进数 èr jìn mǎ shí jìn shù
7-segment display 七段显示器 qī duàn xiǎn shì qì
1.1

Hexadecimal — practical uses

Hex is a compact way to write binary (1 hex digit = 4 bits):

A byte splits into two nibbles; each nibble is one hexadecimal digit A byte is two nibbles; each nibble is one hex digit

  • memory addresses 内存地址 in low-level programming — 0x7FFE.
  • colour values in HTML/CSS — #FF8800.
  • MAC addressesAC:DE:48:00:11:22.

Hex does not change the stored data — it just makes binary easier for humans.

Vocabulary Train
English Chinese Pinyin
memory address 内存地址 nèi cún dì zhǐ
1.1

Character codes

Computers store text as numbers; each character has a numeric code point 码点 set by a character set 字符集.

ASCII

  • ASCII uses 7 bits — 128 code points. Basic Latin letters, digits, punctuation, and control codes.
  • Extended ASCII uses 8 bits — 256 code points; the lower 128 match ASCII, the upper 128 vary by region.

A small ASCII table: the character A is code 65 = 01000001, a is 97 = 01100001, the digit 0 is 48 = 00110000, and space is 32 = 00100000 Each character is stored as a number — a few ASCII code points in denary and binary

Unicode

  • Unicode is a universal character set covering almost every script, plus symbols and emoji.
  • common encodings 编码: UTF-8 (1–4 bytes, ASCII-compatible), UTF-16 (2 or 4 bytes), UTF-32 (fixed 4 bytes).

Why Unicode beats ASCII

  • it represents far more characters (every script, emoji); ASCII covers only basic English.
  • files are portable with no code-page confusion, and allow multilingual text in one document.
  • trade-off: Unicode files are usually larger for English-only text.
Explore

A character is stored as a number

Each character has a code number — 'A' is 65. Flip the bits to see that code in binary and hex, exactly how the computer holds it.

Vocabulary Train
English Chinese Pinyin
code point 码点 mǎ diǎn
character set 字符集 zì fú jí
encoding 编码 biān mǎ
1.2

Bitmap images

Syllabus
Candidates should be able to: Notes and guidance
Show understanding of how data for a bitmapped image are encoded Use and understand the terms: pixel, file header, image resolution, screen resolution, colour depth / bit depth
Perform calculations to estimate the file size for a bitmap image
Show understanding of the effects of changing elements of a bitmap image on the image quality and file size Use the terms: image resolution, colour depth / bit depth
Show understanding of how data for a vector graphic are encoded Use the terms: drawing object, property, drawing list
Justify the use of a bitmap image or a vector graphic for a given task
Show understanding of how sound is represented and encoded Use the terms: sampling, sampling rate, sampling resolution, analogue and digital data
Show understanding of the impact of changing the sampling rate and resolution Including the impact on file size and accuracy

Source: Cambridge International syllabus

A bitmap 位图 image (also called a bitmapped image) stores the colour of every pixel 像素 in a grid. At the start of the file a file header 文件头 records the image's metadata — its width, height and colour depth — so software knows how to read the pixel data that follows.

  • image resolution 图像分辨率: the bitmap's own size, width × height in pixels (e.g. 1920 × 1080).
  • screen resolution 屏幕分辨率: the width × height the display can show. If an image's resolution is larger than the screen it is scaled down to fit; a low-resolution image looks blocky when stretched onto a higher-resolution screen.
  • colour depth 颜色深度 (bit depth 位深度): bits per pixel. 1 bit → black/white; 8 bits → 256 colours; 24 bits → 16.7 million ("true colour").

The same disc stored on three pixel grids, A to C, getting blockier as the pixels grow larger and fewer The same image stored at three resolutions, from high (A) to low (C): fewer, larger pixels mean less detail

File size

$$\text{size in bits} = \text{width} \times \text{height} \times \text{bit depth}.$$

Divide by 8 for bytes, by 1024 for KiB, etc. Example: a $3000 \times 2000$ image at 24 bpp is $3000 \times 2000 \times 24 = 1.44 \times 10^{8}$ bits $\approx 17.2\ \text{MiB}$.

Changing settings

  • lower resolution → smaller file, less detail (looks blocky when enlarged).
  • lower colour depth → smaller file, but smooth shades show banding.
  • higher of either → larger file, better quality.
Vocabulary Train
English Chinese Pinyin
bitmap 位图 wèi tú
pixel 像素 xiàng sù
file header 文件头 wén jiàn tóu
image resolution 图像分辨率 tú xiàng fēn biàn lǜ
screen resolution 屏幕分辨率 píng mù fēn biàn lǜ
colour depth 颜色深度 yán sè shēn dù
bit depth 位深度 wèi shēn dù
1.2

Vector graphics

A vector graphic 矢量图形 stores the instructions to draw the image as a drawing list 绘图列表 — an ordered list of drawing objects 绘图对象 (geometric primitives 图元: lines, curves, polygons, circles). Each drawing object has properties 属性 such as colour, fill, line width and position (coordinates). To show it, the program renders 渲染 the drawing list at any resolution needed.

A simple house drawing made from a rectangle body, triangle roof, circle window, door rectangle and a line, each labelled with its shape type and attributes A vector image is built from labelled geometric shapes, each with attributes

Bitmap vs vector

Task Better choice Why
Photograph Bitmap Complex pixel-level detail can't be described as shapes.
Logo, icon, sign Vector Sharp edges; scales to any size without blur.
Engineering drawing Vector Precise geometry and scaling.
Painting, texture Bitmap Smooth tonal detail per area.

Vector advantage: it scales without losing quality — a vector logo stays sharp at any size, while a bitmap blurs when enlarged. Vector disadvantage: it cannot describe arbitrary pixel detail (photographs).

Side by side, both enlarged: a bitmap diagonal is a jagged staircase of pixels, while a vector diagonal stays a smooth straight line Enlarged, a bitmap's pixels turn jagged; a vector stays smooth at any size

Explore

Computing concept lab

Classify concrete examples by the computing idea they demonstrate.

Vocabulary Train
English Chinese Pinyin
vector graphic 矢量图形 shǐ liàng tú xíng
drawing list 绘图列表 huì tú liè biǎo
drawing object 绘图对象 huì tú duì xiàng
primitive 图元 tú yuán
property 属性 shǔ xìng
render 渲染 xuàn rǎn
1.2

Sound

A continuous wave of analogue data 模拟数据 (the sound) is converted into digital data 数字数据 by sampling 采样:

  • sampling rate 采样率 — samples per second (Hz). CD quality is $44.1\ \text{kHz}$.
  • sampling resolution 采样分辨率 (bit depth) — bits per sample's amplitude 振幅. CD quality is 16 bits.

A smooth analogue sound wave with vertical sample bars at regular time intervals, each bar reading the wave's amplitude Sampling a sound wave: its amplitude is read at each time interval

File size

$$\text{size in bits} = \text{sampling rate} \times \text{resolution} \times \text{duration} \times \text{channels}.$$

A 10-second stereo CD clip: $44100 \times 16 \times 10 \times 2 \approx 1.8\ \text{MiB}$.

Changing settings

  • higher sampling rate → captures higher pitches, larger file.
  • higher sample resolution → finer amplitude steps, less quantisation 量化 noise, larger file.
  • lower of either → smaller file, clear quality loss.

(The sampling rate must be at least twice the highest frequency you want to keep.)

Explore

Sound sampling

y = a sin(bt + c)

Sampling measures a sound wave at regular intervals — a higher rate copies it more truly.

Vocabulary Train
English Chinese Pinyin
analogue data 模拟数据 mó nǐ shù jù
digital data 数字数据 shù zì shù jù
sampling 采样 cǎi yàng
sampling rate 采样率 cǎi yàng lǜ
sampling resolution 采样分辨率 cǎi yàng fēn biàn lǜ
amplitude 振幅 zhèn fú
quantisation 量化 liàng huà
1.3

Compression

Syllabus
Candidates should be able to: Notes and guidance
Show understanding of the need for and examples of the use of compression
Show understanding of lossy and lossless compression and justify the use of a method in a given situation
Show understanding of how a text file, bitmap image, vector graphic and sound file can be compressed Including the use of run-length encoding (RLE)

Source: Cambridge International syllabus

Compression 压缩 reduces file size, saving storage and transmission bandwidth 带宽. Two kinds:

  • lossless 无损 — the original data is recovered exactly (text, programs, ZIP/PNG).
  • lossy 有损 — some detail is dropped for much smaller files (JPEG, MP3, video).

When to use which

  • lossless for documents, source code, medical images — anything needing exact data.
  • lossy for streaming media. Real-time video streaming uses lossy compression because it must send huge amounts of data in real time over limited bandwidth; lossless would not shrink it enough. Raw HD video is gigabytes per minute, so without compression the picture would keep freezing.

Lossless methods

  • run-length encoding 行程编码 (RLE): store "the next $n$ values are $x$" instead of repeating $x$. Great for flat areas; useless for noisy data.
  • dictionary methods 字典编码 (ZIP, PNG): replace repeated byte sequences with a short reference. Good for text and code.
  • Huffman coding 霍夫曼编码: give short codes to common symbols and long codes to rare ones, bringing the average code length near the data's entropy.

An 8 by 8 black-and-white grid showing the letter F, with each row's binary pattern and its shorter run-length code listed beside it Run-length encoding of the letter F in an $8\times8$ black-and-white grid

Lossy methods

  • images (JPEG): drop fine detail and colour differences the eye barely sees.
  • sound (MP3, AAC): drop pitches we hear less well, and quiet sounds hidden by louder ones.
  • video combines spatial 空间 compression (within each frame, like JPEG) with temporal 时间 compression (most frames store only the differences from the previous frame).

A tree classifying compression into lossless (RLE, dictionary/ZIP/PNG, Huffman) and lossy (JPEG images, MP3/AAC sound, video) with examples under each branch Compression methods: lossless versus lossy, with common examples

Explore

Run-length encoding

Watch a run of repeated symbols get squashed into a count — simple lossless compression.

Vocabulary Train
English Chinese Pinyin
compression 压缩 yā suō
bandwidth 带宽 dài kuān
lossless 无损 wú sǔn
lossy 有损 yǒu sǔn
run-length encoding 行程编码 xíng chéng biān mǎ
dictionary methods 字典编码 zì diǎn biān mǎ
Huffman coding 霍夫曼编码 huò fū màn biān mǎ
entropy shāng
spatial 空间 kōng jiān
temporal 时间 shí jiān
1.3

Exam tips

  • Show working for base conversions: denary → binary by place values, binary → hexadecimal in nibbles (groups of 4 bits).
  • For two's complement the MSB is negative; to negate, invert and add 1; watch for overflow when the sign bit flips wrongly.
  • Distinguish bitmap (pixels; file size $=$ width $\times$ height $\times$ colour depth) from vector (drawing commands; scales without loss).
  • Sound file size depends on sample rate $\times$ bit depth $\times$ time — more of each means better quality but a bigger file.
  • Compare lossless vs lossy compression and give a use for each.

Log in or create account

IGCSE & A-Level