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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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
#FF8800is three bytes, one each for red, green and blue.FFis 255 (maximum red),88is 136 (medium green) and00is 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) and0000 0001(1) in 8-bit two's complement gives1000 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.
2is 2 nibbles of 16 so 32;Fis 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
- Describe and use arrays, records, lists, stacks, queues, trees and hash tables, and explain their operations and uses.
A focused answer to WJEC A-Level Computer Science Unit 1 data structures, covering arrays and records, the abstract data types stack and queue, lists, binary trees and hash tables, and when each is the right choice.
- Use Boolean algebra, logic gates and truth tables to represent and simplify logical operations.
A focused answer to WJEC A-Level Computer Science Unit 1 logical operations, covering the logic gates and their truth tables, Boolean expressions and identities, and simplifying a logic circuit.
- Describe the von Neumann architecture, the components of the CPU, the fetch-execute cycle, memory and the storage hierarchy.
A focused answer to WJEC A-Level Computer Science Unit 1 hardware, covering the von Neumann architecture, the CPU components and registers, the fetch-execute cycle, primary and secondary storage, and factors affecting performance.
- Describe files, fields and records, relational databases, normalisation, basic SQL, and validation and verification.
A focused answer to WJEC A-Level Computer Science Unit 1 organisation of data, covering files, fields and records, relational databases and keys, normalisation to remove redundancy, basic SQL, and validation and verification.
- Describe systems, application and utility software, the functions of the operating system, translators, and modes of operation.
A focused answer to WJEC A-Level Computer Science Unit 1 software and systems, covering system, application and utility software, operating system functions, compilers, interpreters and assemblers, and modes of operation.