Skip to main content
WalesComputer ScienceSyllabus dot point

How does a computer represent numbers, text, sound and images using only binary digits?

Represent numbers in binary, hexadecimal and two's complement, perform binary arithmetic, and represent characters, sound and images as binary data.

A focused answer to WJEC A-Level Computer Science Unit 1 data representation, covering binary and hexadecimal, two's complement, binary arithmetic and shifts, and how characters, sound and images are stored as binary.

Generated by Claude Opus 4.813 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

WJEC wants you to move fluently between denary, binary and hexadecimal, to represent signed integers in two's complement, to perform binary addition and shifts, and to explain how non-numeric data (characters, sound and images) is encoded as binary. Data representation underpins the whole of Unit 1, so number-base conversions and two's complement arithmetic appear in almost every paper, often as the opening short-answer questions that set the tone for the whole script.

The answer

Binary and hexadecimal

To convert binary to denary, add the place values where a bit is set: the 8-bit place values are 128, 64, 32, 16, 8, 4, 2, 1. To convert denary to binary, subtract the largest place value that fits, repeatedly, recording a 1 each time. Hexadecimal is read in nibbles: split the binary into groups of four bits from the right, and convert each nibble to its hex digit. Programmers prefer hexadecimal because a long binary string such as 11111111 is far easier to read and write as FF.

Two's complement and signed numbers

Two's complement is used because it lets the processor add and subtract signed numbers with one circuit: subtraction is just addition of the negative. There is also only one representation of zero, unlike the sign-and-magnitude scheme.

Binary arithmetic and shifts

A logical shift left moves every bit one place left and fills with a 0, which multiplies an unsigned value by 2. A logical shift right divides by 2, discarding the bit that falls off the right. Shifts are far faster than full multiplication, so compilers use them for powers of two.

Representing characters, sound and images

Higher sample rate and bit depth give better sound quality but larger files; more pixels (resolution) and greater colour depth give sharper, richer images but again larger files. This trade-off between quality and file size is a recurring exam theme.

Examples in context

Example 1. Why hexadecimal appears in colour codes
A web colour such as #FF8800 is three bytes, one each for red, green and blue. FF is 255 (maximum red), 88 is 136 (medium green) and 00 is no blue. Writing this in binary would need 24 digits; hexadecimal compresses it to six readable characters, which is why memory dumps, MAC addresses and colour codes all use hex.
Example 2. Estimating a sound file size
A 10-second clip sampled at 44,100 samples per second with a 16-bit depth in mono needs 44,100 times 16 times 10 bits, which is about 7.06 million bits or roughly 882 kilobytes. Doubling the bit depth or adding a second channel for stereo doubles the size, which shows directly how quality settings drive storage cost.
Example 3. Overflow in fixed-width arithmetic
Adding 0111 1111 (127) and 0000 0001 (1) in 8-bit two's complement gives 1000 0000, which is minus 128, not 128. The carry into the sign bit has produced overflow because the true answer no longer fits in 8 bits. Recognising this is why WJEC expects you to state the range of an n-bit two's complement number and to spot when a result has overflowed.

Try this

Q1. Convert the hexadecimal number 2F into denary. [2 marks]

  • Cue. 2 is 2 nibbles of 16 so 32; F is 15; 32 + 15 = 47.

Q2. State two factors that increase the file size of a stored image, and explain the effect of each. [2 marks]

  • Cue. More pixels (higher resolution) means more colour values stored; greater colour depth means more bits per pixel. Both raise the total bits and so the file size.

Exam-style practice questions

Practice questions written in the style of WJEC exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

WJEC 20194 marksConvert the denary number 214 into (i) an 8-bit binary number and (ii) a two-digit hexadecimal number.
Show worked answer →

Work down through the place values, then group into nibbles for the hexadecimal.

Binary: the place values are 128, 64, 32, 16, 8, 4, 2, 1. We have 214 = 128 + 64 + 16 + 4 + 2, so the bits set are 128, 64, 16, 4 and 2.

128  64  32  16   8   4   2   1
  1   1   0   1   0   1   1   0

So 214 = 11010110.

Hexadecimal: split into two nibbles, 1101 and 0110. 1101 is 13 which is D; 0110 is 6. So 214 = D6.

Markers reward the correct subtraction of place values, the 8-bit answer, and the correct nibble-to-hex grouping.

WJEC 20213 marksUsing 8-bit two's complement, represent the denary number minus 20, and explain how the most significant bit indicates the sign.
Show worked answer →

Start from positive 20, then apply the two's complement rule of invert and add one.

Positive 20 in 8 bits is 00010100.

Invert every bit: 11101011. Add one: 11101100. So minus 20 is 11101100.

The most significant bit (the leftmost) is the sign bit. A 1 there means the number is negative; a 0 means it is non-negative. The remaining seven bits carry the magnitude in two's complement form.

Markers reward the correct positive representation, the invert-and-add-one method, and the explanation that the most significant bit signals the sign.

Related dot points

Sources & how we know this