Cambridge IGCSE Computer Science Notes

Chapter 1 · Data representation

1.2 Text, sound and images

Computers ultimately store and process binary. This topic explains how characters are given binary codes, how continuously varying sound is sampled into digital values, and how bitmap images are built from pixels, colour depth and resolution.

ASCII & UnicodeSound samplingBitmap imagesInteractive practice

What you need to understand

By the end of Topic 1.2 you should be able to explain why computers encode text using character sets, compare ASCII, Extended ASCII and Unicode, describe how analogue sound becomes digital through sampling, explain sampling rate and sampling resolution, and explain how bitmap images use pixels, colour depth and image resolution. You should also be able to describe the quality-versus-file-size trade-offs created by increasing sampling settings or image detail.

1.2.1

Character sets – ASCII code and Unicode

A computer cannot store a letter such as A, a digit such as 7, or a symbol such as ? directly as a shape. A character set gives each character a numeric code. That number can then be represented in binary and stored or processed by the computer.

Character encoding idea: character → agreed numeric code → binary pattern. The same code must mean the same character to systems using that character set.

Standard ASCII

ASCII stands for American Standard Code for Information Interchange. Standard ASCII uses 7-bit codes, giving code values from 0 to 127. It represents the letters, digits, punctuation and symbols found on a standard English-language keyboard, together with control codes.

Course-book Table 1.2 showing part of the standard ASCII code table in denary, hexadecimal and characters
Course-book Table 1.2: part of the standard ASCII code table, with denary and hexadecimal equivalents.

The codes for related characters are arranged in useful sequences. Digits 0–9 are consecutive, uppercase letters A–Z are consecutive, and lowercase letters a–z are consecutive. In the examples used in the course book, changing between corresponding uppercase and lowercase letters changes one bit position, which makes case conversion efficient.

Example: ASCII code relationships

Uppercase A has denary code 65 and hexadecimal code 41. Lowercase a has denary code 97 and hexadecimal code 61. The characters are different, so their stored binary codes are different even though they represent the same alphabetic letter in different cases.

Extended ASCII

Extended ASCII uses 8 bits, so it can use values from 0 to 255. The extra 128 possible codes can be used for additional characters, including characters from some non-English alphabets and graphical symbols.

Course-book Figure 1.6 showing an Extended ASCII code table
Course-book Figure 1.6: Extended ASCII expands the available codes beyond standard 7-bit ASCII.
Limitation: even Extended ASCII is not enough to represent every writing system used around the world. Different older systems may also map some extended codes to different characters.

Unicode

Unicode was developed to provide a much wider, universal character system. It can represent characters used across many languages and writing systems, making it suitable for global operating systems, browsers, search engines and software.

The Unicode project was intended to create a universal standard, improve efficiency compared with older fragmented character systems, make encodings uniform and unambiguous, and reserve space for private-use characters and symbols.

Course-book Figure 1.7 showing a sample grid of Unicode characters
Course-book Figure 1.7: a sample of Unicode characters from a much larger character repertoire.
Exam distinction: ASCII is a much smaller character set centred on English-language characters; Unicode is designed to represent characters from writing systems around the world.
Check ASCII, Extended ASCII and Unicode.
1.2.2

Representation of sound

Sound begins as vibrations travelling through the air. A sound wave varies continuously, so it is analogue. A computer stores discrete binary values, so the analogue wave must be converted into digital data before it can be stored or processed.

Frequency, wavelength and amplitude

Course-book Figure 1.8 comparing high-frequency and low-frequency wave signals
Course-book Figure 1.8: high- and low-frequency wave signals, showing amplitude and period.

From analogue sound to digital data

An analogue-to-digital converter (ADC) measures the sound wave at regular time intervals. Each measurement records an approximate amplitude value. The sequence of measurements can then be encoded as binary numbers.

  1. Measure the wave amplitude at regular intervals.
  2. Round each measurement to one of the available amplitude levels.
  3. Encode each sampled value as a binary number.
  4. Store the resulting sequence of binary values.
Course-book Figure 1.9 showing a sound wave sampled at regular time intervals
Course-book Figure 1.9: sampling a sound wave at regular time intervals.

Sampling resolution (bit depth)

Sampling resolution, also called bit depth, is the number of bits used to store each sample. More bits create more possible amplitude levels, allowing each measurement to be represented more precisely.

possible amplitude levels = 2sampling resolution
4-bit resolution → 2⁴ = 16 possible levels
8-bit resolution → 2⁸ = 256 possible levels
16-bit resolution → 2¹⁶ = 65,536 possible levels

Sampling rate

Sampling rate is the number of samples taken each second. It is measured in hertz (Hz). For example, 44.1 kHz means 44,100 samples are taken every second.

Increase sampling rate

More measurements are taken each second, so the digital data follows the original wave more closely. The file becomes larger.

Increase sampling resolution

Each sample can use more amplitude levels, reducing rounding error and improving the fidelity of each measurement. The file becomes larger.

Quality and file-size trade-off

Higher sampling resolution can provideBut it also causes
Larger dynamic rangeLarger file size
Better sound qualityLonger transmission/download time
Less sound distortionGreater processing requirements

The course-book example notes that audio CDs use a 16-bit sampling resolution and a 44.1 kHz sampling rate, illustrating how a high sample rate and bit depth can produce high-quality sound.

Remember: higher sampling rate and higher sampling resolution generally improve the accuracy of digital sound, but both increase the amount of data that must be stored. File-size calculations are covered in Topic 1.3.
Check how sound is digitised.
1.2.3

Representation of bitmap images

A bitmap image is made from a two-dimensional grid of pixels (picture elements). Each pixel has a stored binary value that identifies its colour. Put all the pixel values together and the computer can reconstruct the image.

Course-book Figure 1.10 showing example pixel shapes
Course-book Figure 1.10: pixels are the individual picture elements from which a bitmap image is built.

Colour depth

Colour depth is the number of bits used to store the colour of each pixel. If each pixel has more bits, it can represent a larger number of possible colours.

Colour depthPossible colours per pixelExample binary values
1 bit20, 1
2 bits400, 01, 10, 11
3 bits8000 to 111
8 bits2562⁸ possible values
24 bits16,777,2162²⁴ possible values
number of possible colours = 2colour depth

A greater colour depth allows finer colour variation, but more bits must be stored for every pixel, so the image file becomes larger.

Image resolution

Image resolution is the number of pixels that make up the image. It is commonly described using the width × height in pixels. For example, an image of 4096 × 3072 pixels contains:

Example

4096 × 3072 = 12,582,912 pixels

More pixels allow finer detail to be represented. Fewer pixels give the computer less information from which to reconstruct the picture.

Course-book Figure 1.11 showing five versions of a car wheel at progressively lower image resolutions
Course-book Figure 1.11: the same wheel shown at different resolutions. The lowest-resolution image is visibly pixelated.

Higher resolution

More pixels, more visible detail and less obvious pixelation, but a larger file that needs more storage and takes longer to transfer.

Lower resolution

Fewer pixels and a smaller file, but detail is reduced. If resolution becomes too low, individual pixels become obvious and the image looks blocky or fuzzy.

Do not confuse the two: resolution is about the number of pixels; colour depth is about the number of bits used to represent each pixel's colour. Increasing either one increases the amount of image data.
Check bitmap image representation.

Topic 1.2 revision checklist

Explain why text must be encoded using a character set.
Distinguish standard ASCII, Extended ASCII and Unicode.
Explain analogue sound and how an ADC samples it.
Define sampling rate and sampling resolution.
Explain the quality/file-size effects of higher sound sampling settings.
Explain how bitmap images use pixels.
Define colour depth and calculate the number of possible colours.
Define image resolution and explain its effect on quality and file size.
Ready for a mixed Topic 1.2 check?
← Topic 1.1 Number systemsComputer Science contentsTopic 1.3 Data storage and file compression →