Characters, Images and Sound
How Computers Store Text
A computer stores everything as binary — including the letters you type. To do this, every character must be assigned a unique number, which is then stored as its binary equivalent. A character set is the agreed list that maps each character to its code. Without a shared standard, a file created on one system would display differently on another.
7-Bit ASCII
ASCII (American Standard Code for Information Interchange) uses 7 bits per character, allowing \(2^7 = 128\) unique codes (0 to 127). These 128 characters cover upper-case letters, lower-case letters, the digit characters 0–9, punctuation marks and control characters such as “new line”.
The key principle is that codes are sequential within each group. Upper-case A = 65, B = 66, up to Z = 90. Lower-case a = 97, b = 98, up to z = 122. Digit character ‘0’ = 48, ‘1’ = 49, up to ‘9’ = 57. This sequential grouping means you can calculate any character’s code if you know one code in the same group.
In ASCII: upper-case A = 65; lower-case a = 97; digit character ‘0’ = 48. Codes are sequential: ‘P’ = 65 + 15 = 80; ‘m’ = 97 + 12 = 109. ASCII uses 7 bits and represents 128 characters.
Example 1: Given A = 65, what is the code for K?
K is the 11th letter. K = 65 + (11 − 1) = 65 + 10 = 75.
Example 2: A character has ASCII code 104. Given a = 97, what character is it?
104 − 97 = 7. Count 7 letters on from a: b, c, d, e, f, g, h.
Example 3: Given ‘0’ = 48, what is the binary for the character ‘5’?
‘5’ = 48 + 5 = 53. 53 in binary: 32 + 16 + 4 + 1 = 0110101.
Bitmap Images
Every digital image is built from a grid of tiny coloured squares called pixels. Each pixel stores a single colour value in binary. The total number of pixels is determined by the image’s resolution — its width in pixels multiplied by its height in pixels.
Colour depth determines how many different colours are available per pixel. With 1-bit colour depth, only 2 colours are possible. With 8-bit depth, \(2^8 = 256\) colours are possible. With 24-bit depth, over 16 million distinct colours can be represented, appearing photorealistic to the human eye.
Image file size (bits) = width (pixels) × height (pixels) × colour depth (bits). To convert to bytes, divide by 8. Always state the unit explicitly — exam questions may ask for bits, bytes, or larger units.
Problem: A bitmap image is 640 pixels wide and 480 pixels tall with a colour depth of 24 bits per pixel. Calculate the file size in bytes.
Step 1 — File size in bits = 640 × 480 × 24 = 7,372,800 bits.
Step 2 — Convert to bytes: 7,372,800 ÷ 8 = 921,600 bytes.
Common mistakes: (1) Forgetting to multiply by colour depth — the question asks for colour depth separately for a reason. (2) Leaving the answer in bits when bytes are asked for. (3) Dividing by 1,000 instead of 8 when changing bits to bytes.
Sound Representation
Sound is an analogue signal — a continuous wave of changing air pressure. Computers cannot store continuous signals directly. Instead, sound is digitised by taking regular measurements called samples. Each sample captures the amplitude (volume level) at that instant.
Sample Rate and Bit Depth
Sample rate (also called sampling rate) is how many samples are taken per second, measured in hertz (Hz). A higher sample rate means more measurements per second, capturing the original wave more faithfully. The sample interval is the time between consecutive samples — it is the inverse of the sample rate. A sample rate of 44,100 Hz gives a sample interval of roughly 0.023 milliseconds.
Bit depth (also called sample resolution) is the number of bits used to store each sample. More bits means more distinct amplitude levels can be recorded. At 16-bit depth, \(2^{16} = 65,536\) distinct volume levels are possible per sample.
Sound file size (bits) = sample rate (Hz) × bit depth (bits) × duration (seconds). To convert to bytes, divide by 8. Increasing either sample rate or bit depth improves quality but increases file size.
Problem: A 30-second audio clip is recorded at 22,050 Hz with a bit depth of 16 bits. Calculate the file size in bytes.
Step 1 — Size (bits) = 22,050 × 16 × 30 = 10,584,000 bits.
Step 2 — Convert to bytes: 10,584,000 ÷ 8 = 1,323,000 bytes.
Limitations of Binary Representation
When the number of available bits is limited, binary representation becomes less precise. In images, fewer bits per pixel means fewer possible colours and visible banding or “colour blocking” in graduated tones. In sound, a lower bit depth means fewer amplitude levels, producing audible distortion known as quantisation noise. A reduced sample rate may miss rapid sound-wave variations, causing high-frequency detail to be lost.
These limitations represent the fundamental trade-off in data representation: more bits always means greater fidelity, but larger file sizes. Real systems manage this by choosing an appropriate bit width for the task — a voice call needs far less fidelity than a recording studio session.