Skip to content
Cambridge AS & A Level9618

Data Representation

Computer Science 9618 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Data Representation notes as a printable PDF.

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

Read the notes

The full Data Representation notes as text: skim, search, and jump between subtopics.

~12 min read

1. Binary and decimal prefixes

Binary prefixes (kibi, mebi, gibi, tebi) count in powers of 2. Decimal prefixes (kilo, mega, giga, tera) count in powers of 10.

A kibibyte is 1024 bytes. A kilobyte is 1000 bytes. The same pattern holds one step up: a gibibyte is 1024 mebibytes and a terabyte is 1000 gigabytes.

A difference between the two must name the value and the unit. “Bigger” or “smaller” earns nothing.

1 kibibyte = 2¹⁰ bytes = 1024 bytes

1 kilobyte = 10³ bytes = 1000 bytes

1 gibibyte = 1024 mebibytes 1 terabyte = 1000 gigabytes

Examiner insight

“Some candidates confused the two prefixes and stated that a kibibyte was 1000 bytes and a kilobyte was 1024 bytes.” “Some candidates wrote bits instead of bytes, and others omitted any units.”

Worked example 14 marks

Complete the following description.

A kibibyte has a ........ prefix. Three kibibytes is the same as ........ bytes.

A megabyte has a ........ prefix. Two terabytes is the same as ........ gigabytes.

  1. 1

    kibibyte: binary prefix [1]

  2. 2

    three kibibytes = 3 × 1024 = 3072 bytes [1]

  3. 3

    megabyte: decimal (denary) prefix [1]

  4. 4

    two terabytes = 2 × 1000 = 2000 gigabytes [1]

2. Binary, denary and hexadecimal

Hexadecimal is base 16. Its digits are 0 to 9 and A to F, where A to F stand for 10 to 15.

To convert hexadecimal to denary, multiply each digit by its place value: 256, 16, 1 for three digits. To convert denary to hexadecimal, divide by 16, or convert to binary first and group the bits.

To convert between binary and hexadecimal, work in groups of four bits and convert directly. Keep every zero: a zero in the middle of a number is a digit.

A hexadecimal colour code such as `#FC238A` is one practical use: FC is the amount of red, 23 the green and 8A the blue.

A04₁₆ = (10 × 256) + (0 × 16) + 4 = 2564

1011 0011 1010₂ = B3A₁₆

251₁₀ = 1111 1011₂ = FB₁₆

Examiner insight

“When converting the hexadecimal value A04 to binary, some candidates omitted the central zeros and gave an incorrect answer of 10100100 in binary or 164 in denary.” “A small number of candidates introduced an error by converting the binary to denary first, then to hexadecimal, rather than converting directly from binary to hexadecimal.”

Worked example 12 marks

Convert the hexadecimal number A04 into denary. Show your working.

  1. 1

    working: A04 = (10 × 256) + 4 [1]

  2. 2

    answer: 2564 [1]

3. Binary Coded Decimal (BCD)

In BCD each denary digit is stored on its own, as a four-bit group. Convert the digits one at a time, not the whole number.

To write a binary integer as BCD, convert it to denary first, then write each denary digit in four bits.

BCD is used where individual digits are displayed, for example calculators and digital clocks, and in financial calculations where values must be exact.

108₁₀ = 0001 0000 1000_BCD

0001 0100 1001_BCD = 149₁₀

1000 0110 0101_BCD = 865₁₀

Examiner insight

“A very common incorrect response was 95, where candidates had assumed that the value given in the question was BCD and had converted that value to denary.” “Imprecise statements about numbers rather than digits are not enough at this level.”

Worked example 12 marks

Identify one practical application of BCD and justify why BCD is used in this application.

  1. 1

    Application: electronic display, for example a calculator or a digital clock [1]

  2. 2

    Justification: a visual display only needs to show individual digits, and conversion between denary and BCD is easier [1]

4. One’s and two’s complement

Both represent negative binary integers.

The one’s complement of a number is found by inverting every bit. For −120, write +120 in 8 bits, then invert.

The two’s complement is found when you flip each bit then add 1. The most significant bit has a negative place value: -128 in 8 bits, so a leading 1 means a negative number and the range is -128 to 127.

To convert a negative two’s complement number to denary, either invert and add 1 and write a minus sign, or add the place values with the leading bit as negative.

+120 = 01111000 ⇒ one’s complement 10000111

10010110₂ = -128 + 16 + 4 + 2 = -106

-128 ≤ x ≤ 127 (8 bits)

Examiner insight

“A popular incorrect answer was 231 where the binary value had been treated as an unsigned integer. Another common error was a missing minus sign with the correct denary value.” “Many candidates needed to improve their understanding of what is meant by the one’s complement of a binary number.”

Worked example 12 marks

Convert the 12-bit two’s complement binary integer into denary. Show your working.

111110111100

  1. 1

    working: invert 111110111100 → 000001000011, add 1 to give 000001000100 (68) [1]

  2. 2

    denary value: -68 [1]

5. Binary addition, subtraction and overflow

Add column by column from the right and write the carries down as working.

To subtract in binary, convert the number being subtracted to its negative and add, or subtract directly and show the borrows. Converting to denary and subtracting there earns no working marks.

An overflow occurs when the answer is too long to be represented in the number of bits available: it is larger than the maximum positive number, or smaller than the most negative number, that the register can store.

1+1 = 10₂ 1+1+1 = 11₂

10110011 + 01111000 = (1) 00101011 overflow

Examiner insight

“Some candidates need to understand that when the question asks for the subtraction to be completed in binary no working marks will be awarded for converting the binary numbers to denary and performing a denary subtraction.” “A common error was to perform the subtraction the wrong way round and take the two’s complement of hexadecimal 23 instead of the two’s complement of denary 10.”

Worked example 13 marks

Subtract the denary number 10 from the denary number 100 using binary subtraction. Show your working.

  1. 1

    convert both numbers: 100 = 01100100 and 10 = 00001010 [1]

  2. 2

    subtract by converting 10 to −10 and adding: -10 = 11110110, so 01100100 + 11110110 = (1) 01011010 [1]

  3. 3

    answer: 01011010 (the carry out of the leftmost bit is dropped) [1]

6. Character sets

A character set gives every character its own unique binary code. ASCII uses 7 bits, so it represents 128 characters. Extended ASCII uses 8 bits, so it represents 256 characters.

Unicode uses more bits per character, up to 32, so it represents a wider range of characters, including different languages. ASCII is a subset of Unicode.

A word is stored by replacing each character with its code, and the codes are stored in the order of the word. Candidates are not expected to memorise any codes.

2⁷ = 128 (ASCII) 2⁸ = 256 (extended ASCII)

49₁₀ = 31₁₆

Examiner insight

“A common incorrect answer for the number of characters in the extended ASCII character set was 255, the highest denary value, rather than 256.” “The two main points that were required were uniqueness and ordering. For example, statements such as, ‘each character has a code’ are not precise enough.”

Worked example 16 marks

A computer uses the ASCII character set.

(a) State the number of characters that can be represented by the ASCII character set and the extended ASCII character set.

(b) Explain how a word such as ‘HOUSE’ is represented by the ASCII character set.

(c) Unicode is a different character set. The Unicode value for the character ‘1’ is denary value 49.

(i) Write the hexadecimal value for the Unicode character ‘1’.

(ii) Write the denary value for the Unicode character ‘5’.

  1. 1

    (a) ASCII: 128 characters [1]

  2. 2

    (a) extended ASCII: 256 characters [1]

  3. 3

    (b) each character has its own unique code, and each character in the word is replaced by its code [1]

  4. 4

    the codes are stored in the order of the word [1]

  5. 5

    (c)(i) 49 = 3 × 16 + 1, so hexadecimal 31 [1]

  6. 6

    (c)(ii) ‘5’ is four characters after ‘1’ in the sequence, so denary 53 [1]

Recap

  • Binary prefixes: kibi = 1024 bytes. Decimal prefixes: kilo = 1000 bytes. Name the value and the unit.
  • Hexadecimal digits A to F are 10 to 15. Convert binary and hexadecimal in groups of four bits and keep the zeros.
  • BCD: each denary digit in its own four bits. Used for displays and exact financial values.
  • One’s complement: invert every bit. Two’s complement: invert and add 1.
  • In 8 bits the two’s complement range is −128 to 127. The leading bit has place value -128.
  • Binary subtraction: add the negative of the number, or subtract directly. Show the carries or borrows.
  • Overflow: the answer is too long for the number of bits available.
  • ASCII 7 bits, 128 characters. Extended ASCII 8 bits, 256 characters. Unicode up to 32 bits.

End-of-chapter exercise

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

  1. A file is 4 kibibytes in size. State its size in bytes.1 mark
    Answer
    1. 4 × 1024 = 4096 bytes [1].

    Trap: Using 1000 treats kibi as kilo. A kibibyte is 1024 bytes.

  2. Convert the hexadecimal number 5A0 into denary. Show your working.2 marks
    Answer
    1. 5 × 256 + 10 × 16 + 0 × 1 = 1280 + 160 [1]. = 1440 [1].

    Trap: Forgetting the 256 place value: three hexadecimal digits have place values 256, 16 and 1.

  3. Convert the denary number 156 into Binary Coded Decimal (BCD).2 marks
    Answer
    1. Convert each digit on its own: 1 = 0001, 5 = 0101, 6 = 0110 [1]. BCD = 0001 0101 0110 [1].

    Trap: Converting the whole number to unsigned binary gives 10011100, which is not BCD.

  4. A digital clock stores the minutes value 47 in BCD. (a) Write the BCD for 47. (b) Give one reason why BCD suits a digital clock display.2 marks
    Answer
    1. (a) 4 = 0100 and 7 = 0111, so 0100 0111 [1].
    2. (b) A display only needs to show individual digits [1].

    Trap: Writing that BCD suits “numbers”. Examiners want the point about digits.

  5. Give the 8-bit two’s complement representation of the denary number -45.2 marks
    Answer
    1. 45 = 00101101 [1]. Invert to give 11010010, then add 1 to give 11010011 [1].

    Trap: Stopping after the inversion gives the one’s complement, 11010010.

  6. Convert the 8-bit two’s complement binary integer 10110100 into denary.2 marks
    Answer
    1. The leading bit is 1, so the number is negative. Invert to give 01001011, add 1 to give 01001100, which is 76 [1]. The value is -76 [1].

    Trap: Reading it as unsigned gives 180. Giving 76 with no minus sign also loses the mark.

  7. Two unsigned 8-bit integers, 11010110 and 01110101, are added in an 8-bit register. Show the addition in binary, with the carries, and state what happens.3 marks
    Answer
    1. Carries written above the columns [1]. 11010110 + 01110101 = (1) 01001011 [1]. The sum is too long for 8 bits, so an overflow occurs [1].

    Trap: Writing a 9-bit answer and not naming the overflow.

  8. Subtract the denary number 27 from the denary number 90 using 8-bit binary subtraction. Show your working.4 marks
    Answer
    1. 90 = 01011010 and 27 = 00011011 [1]. Flip each bit of 27 and add 1: -27 = 11100101 [1].
    2. 01011010 + 11100101 = (1) 00111111 [1]. Drop the carry out: 00111111 [1].

    Trap: Taking the two’s complement of 90 instead of 27 is the wrong way round.

  9. A device shows a scrolling message of 2560 characters. (a) The message is stored in extended ASCII. Calculate its size in kibibytes. (b) The message is changed to Unicode, using 32 bits per character. Calculate its new size in bytes. (c) The device has 10 kilobytes of free memory. State whether the Unicode message fits. Show your working.5 marks
    Answer
    1. (a) 8 bits is 1 byte per character, so 2560 bytes [1]. 2560 ÷ 1024 = 2.5 kibibytes [1].
    2. (b) 32 bits is 4 bytes per character. 2560 × 4 = 10240 bytes [1].
    3. (c) 10 kilobytes = 10 × 1000 = 10000 bytes [1]. 10240 > 10000, so it does not fit [1].

    Trap: Taking a kilobyte as 1024 bytes makes the free memory 10240 bytes, so the message wrongly seems to fit.

  10. A data logger stores each change in a reading as an 8-bit two’s complement integer. Two changes are 10011100 and 11001110. (a) Convert each change into denary. Show your working. (b) Add the two changes using binary addition in an 8-bit register. Show your working. (c) State the denary value the register now holds. Explain why it is not the true total.7 marks
    Answer
    1. (a) -128 + 16 + 8 + 4 = -100 [1]. -128 + 64 + 8 + 4 + 2 = -50 [1].
    2. (b) Carries shown [1]. 10011100 + 11001110 = (1) 01101010; the register holds 01101010 [1].
    3. (c) Leading bit 0: +106 [1]. True total -150 [1], below -128, the most negative 8-bit value, so overflow [1].

    Trap: Reading the patterns as unsigned (156 and 206), or trusting the 8-bit result: two negative numbers cannot add to a positive one.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
“a kibibyte is bigger than a kilobyte”a kibibyte is 1024 bytes (binary prefix); a kilobyte is 1000 bytes (decimal prefix)
“each character has a code”each character has a unique code, stored in the order of the word
convert to denary, subtract, convert backbinary subtraction with the working shown, for example adding the two’s complement
extended ASCII has 255 charactersextended ASCII has 256 characters

Frequently asked questions

What is the difference between a kibibyte and a kilobyte?
A kibibyte is 1024 bytes and a kilobyte is 1000 bytes. Kibi is a binary prefix that counts in powers of 2, while kilo is a decimal prefix that counts in powers of 10. When you compare the two, name the value and the unit, because “bigger” or “smaller” earns nothing.
How do you convert a hexadecimal number to denary?
Multiply each digit by its place value and add the results. For three digits the place values are 256, 16 and 1, and A to F stand for 10 to 15. For example, A04 is (10 × 256) + (0 × 16) + 4, which gives 2564 in denary.
How is Binary Coded Decimal (BCD) used to store a number?
In BCD each denary digit is stored on its own as a four-bit group. For example, 108 is 0001 0000 1000 in BCD. Convert the digits one at a time, not the whole number. BCD is used in calculators, digital clocks and financial calculations where values must be exact.
How do you find the two's complement of a negative binary number?
Invert every bit, then add 1. For example, 45 is 00101101, which inverts to 11010010 and then becomes 11010011 as −45. Stopping after the inversion gives the one's complement instead. In 8 bits the most significant bit has place value −128, so the range is −128 to 127.
How do you subtract binary numbers, and what is overflow?
Convert the number being subtracted to its negative, using two's complement, and add it, showing the carries. Drop the carry out of the leftmost bit. Overflow happens when the answer is too long for the number of bits available, so it is larger than the maximum positive number or smaller than the most negative number that the register can store.
What mistake do students make when they convert a denary number to BCD?
They convert the whole number to unsigned binary instead of converting each digit to four bits. For 156, unsigned binary gives 10011100, which is not BCD. The correct BCD is 0001 0101 0110, one four-bit group for each of 1, 5 and 6.

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