Cambridge AS & A Level9608

Data representation (1.1)

Computer Science 9608 Chapter Notes

What this chapter covers

Data representation
ShareWhatsAppPost
Data representation (1.1) notes

Unable to load PDF

The notes viewer could not load. Please refresh the page.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Data representation (1.1) notes as text: skim, search, and jump between subtopics.

~17 min read

1. Understanding Number Systems: Denary and Binary

Humans count using the denary (or decimal) system, which is base-10. It uses ten distinct digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). The position of a digit determines its value, based on powers of 10. For example, the number 123 is (1 × 10²) + (2 × 10¹) + (3 × 10⁰). Computers, however, are built from electronic circuits that can only be in one of two states: on or off. These states are represented by the binary system, which is base-2. It uses only two digits: 1 (on) and 0 (off). These binary digits are called 'bits'. All data inside a computer, from numbers to text to images, is ultimately stored as a sequence of bits. The value of a binary number is determined by powers of 2.

Denary Place Values: ... 10³, 10², 10¹, 10⁰

Binary Place Values: ... 2³, 2², 2¹, 2⁰

Key term

Bit: The smallest unit of data in a computer, representing a single binary digit, either a 0 or a 1.

Examiner insight

Examiners award marks for showing clear understanding of place values in both denary and binary systems.

Fun fact

The word 'bit' is a shortened form of 'binary digit', first coined by statistician John Tukey in 1947.

Worked example 12 marks

What is the largest denary number that can be represented using 4 bits?

  1. 1

    Step 1: Identify the largest binary number possible with 4 bits. This is when all bits are '1', so the number is 1111.

  2. 2

    Step 2: Write down the place values for a 4-bit binary number. From right to left, they are 2⁰, 2¹, 2², 2³. These are 1, 2, 4, and 8.

  3. 3

    Step 3: Calculate the denary value by summing the place values where the bit is '1'.

  4. 4

    Calculation: (1 × 8) + (1 × 4) + (1 × 2) + (1 × 1) = 8 + 4 + 2 + 1 = 15.

  5. 5

    Answer: The largest denary number is 15.

Recap

  • The denary system is base-10, using digits 0-9.
  • The binary system is base-2, using digits 0 and 1 (bits).
  • Computers use binary to represent the on/off states of electronic circuits.
  • The position of a digit in any number system determines its place value.

Quick check

  1. What is the base of the denary number system?1 mark
  2. How many unique digits are used in the binary number system?1 mark

2. Converting Between Denary and Binary

Being able to convert between denary and binary is a fundamental skill. To convert a binary number to denary, you sum the place values of all the '1's. A place value grid is very helpful for this. To convert a denary number to binary, you use repeated division by 2. You divide the denary number by 2, write down the remainder (which will be 0 or 1), and use the result for the next division. You repeat this until the result is 0. The binary number is formed by reading the remainders from the bottom up.

Binary to Denary: Sum of (bit × 2^place_value)

Denary to Binary: Repeatedly divide number by 2 and record remainders in reverse order.

Key term

Place Value: The numerical value that a digit has by virtue of its position in a number.

Common pitfall

Forgetting to read the remainders from bottom to top when converting from denary to binary, leading to a reversed binary number.

Worked example 12 marks

Convert the binary number 110101 to denary.

  1. 1

    Step 1: Write the binary number under a place value grid.

  2. 2

    Grid: | 32 | 16 | 8 | 4 | 2 | 1 |

  3. 3

    Binary: | 1 | 1 | 0 | 1 | 0 | 1 |

  4. 4

    Step 2: Add the place values that have a '1' underneath them.

  5. 5

    Calculation: 32 + 16 + 4 + 1 = 53.

  6. 6

    Answer: The denary equivalent is 53.

Worked example 23 marks

Convert the denary number 86 to an 8-bit binary number.

  1. 1

    Step 1: Use repeated division by 2, noting the remainder each time.

  2. 2

    86 ÷ 2 = 43 remainder 0

  3. 3

    43 ÷ 2 = 21 remainder 1

  4. 4

    21 ÷ 2 = 10 remainder 1

  5. 5

    10 ÷ 2 = 5 remainder 0

  6. 6

    5 ÷ 2 = 2 remainder 1

  7. 7

    2 ÷ 2 = 1 remainder 0

  8. 8

    1 ÷ 2 = 0 remainder 1

  9. 9

    Step 2: Read the remainders from the bottom up: 1010110.

  10. 10

    Step 3: Pad with leading zeros to make it an 8-bit number. The question asks for an 8-bit number, and we have 7 bits.

  11. 11

    Answer: 01010110.

Recap

  • To convert binary to denary, add up the place values for each '1' bit.
  • To convert denary to binary, use the method of repeated division by 2.
  • Always read the remainders from the bottom up for denary to binary conversion.
  • If a specific number of bits is required (e.g., 8-bit), pad the left with zeros.

Quick check

  1. Convert the denary number 12 to binary.1 mark
  2. What is the denary value of the binary number 1101?1 mark

3. The Hexadecimal Number System

While computers use binary, long strings of 1s and 0s are difficult for humans to read and write without making errors. The hexadecimal system (or 'hex') is a base-16 system used as a more compact, human-friendly way to represent binary data. It uses 16 symbols: the digits 0-9 and the letters A-F to represent the denary values 10-15. The key relationship is that one hexadecimal digit represents exactly four binary bits (a nibble). This makes conversion between binary and hex very simple and is why it's widely used in computing for things like memory addresses, MAC addresses, and HTML colour codes.

1 Hexadecimal Digit = 4 Binary Bits (1 Nibble)

Hex Digits: 0-9, A(10), B(11), C(12), D(13), E(14), F(15)

Key term

Hexadecimal: A base-16 number system using 16 symbols (0-9 and A-F) as a human-friendly representation of binary values.

Examiner insight

Marks are often awarded for explaining *why* hexadecimal is used, not just what it is. Focus on its role as a more compact and less error-prone representation of binary for humans.

Fun fact

Web colour codes like #FFD700 (Gold) are hexadecimal. The first pair (FF) is the amount of red, the second (D7) is green, and the third (00) is blue.

Worked example 12 marks

Give two reasons why hexadecimal is used in computer science.

  1. 1

    Reason 1: It is more compact than binary, making long binary numbers shorter and easier for humans to read and transcribe. For example, FF is much shorter than 11111111.

  2. 2

    Reason 2: It is less prone to human error when copying or writing values compared to long binary strings. It is also simple to convert between hexadecimal and binary because each hex digit maps to a 4-bit pattern.

Recap

  • Hexadecimal is a base-16 number system.
  • It uses symbols 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, F=15.
  • Hex is used as a shorthand for binary because it's more compact and less error-prone for humans.
  • One hexadecimal digit corresponds to a group of four bits (a nibble).

Quick check

  1. What denary value does the hexadecimal digit 'E' represent?1 mark
  2. Give one example of where hexadecimal numbers are used.1 mark

4. Mastering Hexadecimal Conversions

Converting between number systems is a key skill. Binary-to-Hex is the easiest: starting from the right, split the binary number into groups of four (nibbles), then convert each nibble into its corresponding hex digit. Hex-to-Binary is the reverse: convert each hex digit into its 4-bit binary equivalent. For Hex-to-Denary, use place values based on powers of 16. For Denary-to-Hex, use repeated division by 16, recording the remainders and converting any remainder from 10-15 into its A-F character. As with binary, read the remainders from the bottom up.

Hex to Denary: Σ(digit × 16^place_value)

Denary to Hex: Repeatedly divide by 16, record remainders.

Key term

Nibble: A group of four bits, which can be conveniently represented by a single hexadecimal digit.

Common pitfall

When converting from denary to hexadecimal, students often forget to convert remainders of 10-15 into their corresponding A-F characters.

Worked example 13 marks

Convert the hexadecimal number 3A2 to denary.

  1. 1

    Step 1: Write the hex number under a place value grid for base-16. The place values are powers of 16 (..., 16², 16¹, 16⁰).

  2. 2

    Grid: | 256 (16²) | 16 (16¹) | 1 (16⁰) |

  3. 3

    Hex: | 3 | A | 2 |

  4. 4

    Step 2: Convert any letters to their denary values. A = 10.

  5. 5

    Step 3: Multiply each digit by its place value and sum the results.

  6. 6

    Calculation: (3 × 256) + (10 × 16) + (2 × 1) = 768 + 160 + 2 = 930.

  7. 7

    Answer: The denary equivalent is 930.

Worked example 22 marks

Convert the binary number 101100011100 to hexadecimal.

  1. 1

    Step 1: Split the binary number into groups of four (nibbles), starting from the right.

  2. 2

    Binary: 1011 0001 1100

  3. 3

    Step 2: Convert each 4-bit group into its denary equivalent, then its hex digit.

  4. 4

    1011 = (8+2+1) = 11, which is 'B' in hex.

  5. 5

    0001 = 1, which is '1' in hex.

  6. 6

    1100 = (8+4) = 12, which is 'C' in hex.

  7. 7

    Step 3: Combine the hexadecimal digits.

  8. 8

    Answer: B1C.

Recap

  • To convert from binary to hex, group bits into fours from the right and convert each group.
  • To convert from hex to binary, change each hex digit into its 4-bit binary pattern.
  • To convert from hex to denary, use place values of powers of 16.
  • To convert from denary to hex, use repeated division by 16 and read remainders upwards.

Quick check

  1. Convert the hexadecimal number 5F to binary.1 mark
  2. Convert the denary number 26 to hexadecimal.1 mark

5. Units of Digital Information

Data in a computer is measured in specific units. The smallest unit is a bit (0 or 1). Bits are grouped together to form larger units. A group of 4 bits is a nibble, and a group of 8 bits is a byte. The byte is the fundamental unit for measuring memory and storage size. For larger amounts of data, metric prefixes are used: Kilo (K), Mega (M), Giga (G), and Tera (T). In computing, these prefixes can have two meanings. Historically, they were based on powers of 2 (e.g., 1 Kilobyte = 1024 bytes). However, it is now common practice, especially for storage and data transfer speeds, to use the standard metric meaning based on powers of 10 (e.g., 1 Kilobyte = 1000 bytes). For exams, unless told otherwise, it is often acceptable to use the 1000-based units as it simplifies calculations. Always state your assumption.

1 Nibble = 4 Bits

1 Byte = 8 Bits

1 Kilobyte (KB) = 1000 Bytes

1 Megabyte (MB) = 1000 Kilobytes

1 Gigabyte (GB) = 1000 Megabytes

1 Terabyte (TB) = 1000 Gigabytes

Key term

Byte: A group of eight bits, which is the standard unit for measuring digital information and computer storage.

Examiner insight

In calculation questions, show your working clearly, stating whether you are using 1000 or 1024 for conversions between units like KB and MB. Often, using 1000 is acceptable and simplifies the arithmetic.

Worked example 13 marks

A digital camera produces photos with an average file size of 4.5 MB. How many complete photos can be stored on a 16 GB memory card? (Use 1 GB = 1000 MB).

  1. 1

    Step 1: Convert the memory card capacity to the same units as the photo file size (MB).

  2. 2

    Card capacity = 16 GB = 16 × 1000 MB = 16000 MB.

  3. 3

    Step 2: Divide the total capacity by the size of a single photo.

  4. 4

    Number of photos = Total capacity / Size per photo = 16000 MB / 4.5 MB.

  5. 5

    Calculation: 16000 / 4.5 ≈ 3555.55

  6. 6

    Step 3: Since you cannot store a fraction of a photo, round the answer down to the nearest whole number.

  7. 7

    Answer: 3555 complete photos can be stored.

Recap

  • The smallest unit of data is a bit; 8 bits make a byte.
  • File sizes and memory capacity are measured in Bytes, Kilobytes (KB), Megabytes (MB), Gigabytes (GB), and Terabytes (TB).
  • For calculations, you can often assume 1 KB = 1000 Bytes, but state this assumption.
  • To find how many files fit in a storage space, divide the total space by the file size.

Quick check

  1. How many bits are in 5 bytes?1 mark
  2. A file is 2500 KB. Express this size in MB.1 mark

6. Representing Text: ASCII and Unicode

Every character on your keyboard needs a unique binary code so the computer can process and store it. Character sets are standards that define these codes. The most common early standard was ASCII (American Standard Code for Information Interchange). Standard ASCII uses 7 bits, allowing it to represent 128 different characters (2⁷ = 128), which is enough for all uppercase and lowercase English letters, numbers, and common punctuation. Extended ASCII uses 8 bits (1 byte) to represent 256 characters. However, ASCII is insufficient for global use. Unicode is a modern, universal standard that aims to represent every character from every language. It uses 16 or even 32 bits per character, allowing for millions of unique codes, covering everything from ancient scripts to modern emojis.

Number of possible characters = 2^n (where n is the number of bits per character)

Key term

Unicode: A universal character encoding standard that assigns a unique number to every character, symbol, and emoji across all languages and scripts.

Common pitfall

Confusing ASCII and Unicode. Remember ASCII is a smaller, older subset of Unicode, primarily for English, while Unicode is the modern, all-encompassing standard.

Fun fact

The 'face with tears of joy' emoji 😂 has the Unicode code point U+1F602. In binary, this is a long string that your computer interprets to display the emoji.

Worked example 12 marks

The 7-bit ASCII code for the character 'M' is 1001101. The character 'N' comes immediately after 'M'. What is the 7-bit ASCII code for 'N'?

  1. 1

    Step 1: Understand that characters in ASCII are stored in sequence. The code for 'N' will be the code for 'M' plus one.

  2. 2

    Step 2: Convert the binary for 'M' to denary to make the addition easier. 1001101 = 64 + 8 + 4 + 1 = 77.

  3. 3

    Step 3: Add 1 to the denary value: 77 + 1 = 78.

  4. 4

    Step 4: Convert the new denary value (78) back to 7-bit binary.

  5. 5

    78 in binary is 1001110. (64 + 8 + 4 + 2).

  6. 6

    Answer: The 7-bit ASCII code for 'N' is 1001110.

Worked example 22 marks

Explain why Unicode was introduced as a replacement for ASCII.

  1. 1

    Explanation: ASCII uses only 7 or 8 bits, allowing for a maximum of 128 or 256 characters. This is sufficient for the English language and some symbols, but it cannot represent the vast number of characters used in other languages worldwide (e.g., Chinese, Arabic, Cyrillic). Unicode was introduced to solve this problem by providing a much larger space for character codes (using 16 or 32 bits), allowing it to represent characters from all known languages and a wide range of symbols, making software and data exchange truly global.

Recap

  • Characters are stored in computers using binary codes defined by a character set.
  • ASCII is an early 7-bit or 8-bit character set, mainly for English.
  • Unicode is a modern, universal standard that can represent characters from all languages.
  • The number of bits used per character determines the size of the character set.
  • Using n bits allows for 2^n unique characters.

Quick check

  1. What is the main advantage of Unicode over ASCII?1 mark
  2. If a system uses 8-bit ASCII, how many bytes are needed to store the word 'COMPUTER'?1 mark

7. Bitmap Image Representation

A bitmap image is a digital picture made up of a grid of tiny dots called pixels (picture elements). The computer stores information about the colour of each individual pixel. The two key properties that determine a bitmap's quality and file size are its resolution and colour depth. Resolution is the number of pixels in the grid, usually expressed as width × height (e.g., 1920 × 1080). Colour depth is the number of bits used to store the colour of each pixel. A higher colour depth allows for more colours (e.g., 8 bits = 2⁸ = 256 colours; 24 bits = 2²⁴ ≈ 16.7 million colours) but increases the file size. The total file size can be calculated by multiplying the number of pixels by the colour depth.

Image file size (in bits) = Image Width (pixels) × Image Height (pixels) × Colour Depth (bits)

Image file size (in bytes) = (Width × Height × Colour Depth) / 8

Key term

Colour Depth: The number of bits used to represent the colour of a single pixel in a bitmap image.

Examiner insight

For file size calculations, examiners expect you to show the formula, substitute the values, and give the final answer in an appropriate unit (e.g., KB or MB), showing the conversion steps.

Fun fact

The original Macintosh computer in 1984 had a black and white screen. Its colour depth was just 1 bit, meaning each pixel could only be on (white) or off (black).

Worked example 14 marks

Calculate the file size in kilobytes (KB) for a bitmap image that is 1000 pixels wide by 800 pixels high with a colour depth of 24 bits. Assume 1 KB = 1000 bytes.

  1. 1

    Step 1: Calculate the total number of pixels in the image.

  2. 2

    Total Pixels = Width × Height = 1000 × 800 = 800,000 pixels.

  3. 3

    Step 2: Calculate the total file size in bits.

  4. 4

    File Size (bits) = Total Pixels × Colour Depth = 800,000 × 24 = 19,200,000 bits.

  5. 5

    Step 3: Convert the file size from bits to bytes by dividing by 8.

  6. 6

    File Size (bytes) = 19,200,000 / 8 = 2,400,000 bytes.

  7. 7

    Step 4: Convert the file size from bytes to kilobytes (KB) by dividing by 1000.

  8. 8

    File Size (KB) = 2,400,000 / 1000 = 2400 KB.

  9. 9

    Answer: The file size is 2400 KB.

Recap

  • Bitmap images are composed of a grid of pixels.
  • Image resolution (width × height) and colour depth (bits per pixel) determine quality and size.
  • A higher colour depth means more available colours but a larger file size.
  • File size in bits is calculated as: Width × Height × Colour Depth.
  • Remember to divide by 8 to convert the file size from bits to bytes.

Quick check

  1. What is meant by the term 'pixel'?1 mark
  2. An image has a colour depth of 16 bits. How many different colours can be represented?1 mark

8. Vector Graphics Representation

Unlike bitmaps, which store a map of pixels, vector graphics store an image as a set of mathematical instructions. Instead of saving every pixel of a circle, a vector graphic stores the properties of the circle: the coordinates of its centre, its radius, its line colour, and its fill colour. This approach has two major advantages. Firstly, vector graphics are scalable; they can be resized to any dimension, from a tiny icon to a giant billboard, without any loss of quality or 'pixelation'. Secondly, for images made of simple shapes and lines (like logos, charts, and diagrams), the file size is often much smaller than a corresponding high-resolution bitmap. However, they are not suitable for representing photorealistic images.

Key term

Vector Graphic: An image created from mathematical objects like lines, curves, and shapes, which can be scaled to any size without losing quality.

Examiner insight

When comparing bitmap and vector graphics, be specific about the advantages of each. For vector, focus on scalability and file size for geometric images. For bitmap, focus on photographic realism.

Fun fact

The fonts you are reading right now are a type of vector graphic. That's why you can zoom in on the text and the edges of the letters always stay perfectly sharp.

Worked example 13 marks

A company needs a new logo that will be used on small business cards and large billboards. Should they use a bitmap or a vector graphic? Justify your answer.

  1. 1

    Choice: They should use a vector graphic.

  2. 2

    Justification 1 (Scalability): The primary reason is scalability. A vector graphic can be enlarged to billboard size without becoming pixelated or losing quality, as it is recalculated from mathematical instructions. A bitmap would look blocky and unprofessional when scaled up.

  3. 3

    Justification 2 (File Size): The file size of a vector logo is typically small and remains small regardless of its display size, making it easy to store and transmit.

Recap

  • Vector graphics store images as a list of mathematical objects and their properties.
  • The key advantage of vector graphics is scalability without loss of quality.
  • Vector files are often smaller than bitmap files for geometric images like logos and charts.
  • Vector graphics are not suitable for photorealistic images, which are better stored as bitmaps.
  • Examples of vector objects include lines, circles, rectangles, and paths.

Quick check

  1. State one key advantage of vector graphics over bitmap graphics.1 mark
  2. Give an example of an image that would be better stored as a vector graphic.1 mark

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. Convert the denary number 93 to an 8-bit binary number. Show your working.2 marks
  2. Convert the hexadecimal number D8 to a denary number. Show your working.2 marks
  3. Explain why hexadecimal numbers are often used in computer science to represent binary data.2 marks
  4. A text file stores the word 'Exam'. Using 8-bit ASCII, where 'E' is 69, 'x' is 120, 'a' is 97, and 'm' is 109, calculate the size of this word in bits. Show your working.2 marks
  5. Calculate the uncompressed file size in megabytes (MB) of a bitmap image with a resolution of 1920 x 1080 pixels and a colour depth of 24 bits. Assume 1 MB = 1,000,000 bytes.4 marks
  6. Convert the 16-bit binary number 1110010110101101 into hexadecimal. Show your working.2 marks
  7. Compare and contrast the use of bitmap and vector graphics for storing a simple diagram, such as a flowchart. Your answer should refer to file size, scalability, and how the image is stored.5 marks
  8. A digital camera stores photos. Each photo is 4000 x 3000 pixels with a 24-bit colour depth. The camera has a 64 GB memory card. Calculate how many photos can be stored on the card. (Assume 1 GB = 1000 MB, 1 MB = 1000 KB, 1 KB = 1000 Bytes).5 marks
  9. Unicode is a successor to ASCII. Explain the main limitation of 7-bit ASCII and describe how Unicode overcomes this limitation.3 marks
  10. How many unique values can be represented using 10 bits?2 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters