You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Computers store and move everything — numbers, text, instructions, colours, sound — as patterns of binary digits. This lesson builds fluent, two-way conversion between the three number systems that A-Level expects you to handle on sight: binary (base 2), denary (base 10) and hexadecimal (base 16), and explains why each one earns its place in computing.
This lesson addresses the H446 1.4.1 Data Types content on representing positive integers and the use of multiple number bases:
(Phrasing here is a paraphrase of the specification content, not a verbatim quote.)
Computer hardware is built from billions of transistors, each acting as a switch that is either on or off. Because there are only two reliably distinguishable states, the natural counting system for hardware has only two digits: binary. We could in principle build hardware that distinguished ten voltage levels and worked directly in denary, but the more levels a circuit must tell apart, the more sensitive it is to electrical noise and the more it costs to manufacture reliably. Two states — clearly "low" versus clearly "high" — give the largest possible noise margin, which is why essentially all digital computing is binary at the physical level.
The price of binary is human ergonomics. A single 32-bit memory address is thirty-two ones and zeros: tedious to write, hard to compare at a glance, and very easy to miscopy. This is where the other two systems earn their keep. Denary is the system we think in, so input, output and everyday reasoning are done in base 10. Hexadecimal is the bridge: because 16=24, one hex digit stands in for exactly four bits, so a 32-bit value collapses to just eight hex digits with no loss of information and no awkward arithmetic. Hex is therefore not a different way of counting for the computer — internally it is still binary — it is a human-facing shorthand for binary that happens to line up perfectly with nibble boundaries.
A useful way to keep the three straight is to remember who each base is for:
| System | Base | Digits Used | Example | Who it is for |
|---|---|---|---|---|
| Binary | 2 | 0, 1 | 11010110 | The hardware — the physical representation |
| Denary | 10 | 0-9 | 214 | Humans doing everyday arithmetic |
| Hexadecimal | 16 | 0-9, A-F | D6 | Humans reading/writing binary compactly |
The key insight, which underpins every conversion in this lesson, is that positional notation is the same idea in every base: the value of a number is the sum of (each digit × the base raised to that column's position). Only the base changes. Once that clicks, conversions stop being recipes to memorise and become a single principle applied three ways.
Each digit in a binary number is a bit (binary digit). As with any positional number system, each column has a place value, and here each place value is a power of the base — powers of 2, increasing right to left from 20:
27128266425322416238224212201
The value of a binary number is the sum of the place values where a 1 appears. Formally, for bits b7b6…b1b0:
N=∑i=07bi×2i
| Term | Definition |
|---|---|
| Bit | A single binary digit (0 or 1) — the smallest unit of information |
| Nibble | 4 bits — exactly one hexadecimal digit |
| Byte | 8 bits — the smallest individually addressable unit in most architectures |
| Word | The number of bits a processor handles in one operation (commonly 32 or 64 bits) |
The word size is an architectural property of a particular processor, not a fixed universal value — a 64-bit CPU has a 64-bit word, an 8-bit microcontroller has an 8-bit word. It influences how much data the processor can move and operate on at once, the largest integer it can handle natively, and (closely related) how much memory it can address. The byte, by contrast, is essentially universal: 8 bits, and the unit in which memory capacity is quoted.
If all n bits are used to store a non-negative ("unsigned") integer, the smallest value is 0 (all bits clear) and the largest is 2n−1 (all bits set). The reason it is 2n−1 and not 2n is that one of the 2n distinct patterns must represent zero.
range=0 to 2n−1,number of distinct values=2n
| Bits (n) | Distinct values 2n | Largest unsigned value 2n−1 |
|---|---|---|
| 4 | 16 | 15 |
| 8 | 256 | 255 |
| 16 | 65,536 | 65,535 |
| 32 | 4,294,967,296 | 4,294,967,295 |
Each extra bit doubles the number of representable values, which is why bit width matters so much: going from 8 to 16 bits does not double the range, it squares the count of values (from 256 to 65,536). This exponential relationship is the same one that governs how many memory locations an address bus can reach and how many colours a given colour depth can display, so it is worth internalising now.
Counting upward in binary works exactly like counting in denary, except you "carry" when a column reaches 2 rather than 10. Watching the pattern reinforces place value:
| Denary | Binary | Denary | Binary |
|---|---|---|---|
| 0 | 0000 | 5 | 0101 |
| 1 | 0001 | 6 | 0110 |
| 2 | 0010 | 7 | 0111 |
| 3 | 0011 | 8 | 1000 |
| 4 | 0100 | 9 | 1001 |
Notice how the least significant bit alternates every step (0,1,0,1…), the next bit alternates every two steps, the next every four, and so on — each column toggles half as often as the one to its right. That regularity is precisely what positional powers of 2 encode, and it is also why a right shift (dropping the rightmost bit) halves a value.
Use the place-value subtraction method: starting from the largest power of 2 that fits, subtract it, place a 1 in that column, and repeat with the remainder. Where a place value does not fit, write a 0.
173−128=45(place 1 under 128) 45−32=13(place 1 under 32) 13−8=5(place 1 under 8) 5−4=1(place 1 under 4) 1−1=0(place 1 under 1)
All remaining columns (64, 16, 2) take a 0:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
17310=101011012
Check by converting back: 128+32+8+4+1=173. Correct.
200−128=72(1 under 128) 72−64=8(1 under 64) 8−8=0(1 under 8)
Columns 32, 16, 4, 2 and 1 take a 0:
20010=110010002
A second, equivalent method is repeated division by 2, reading remainders from bottom to top — 200÷2=100 r 0, 100÷2=50 r 0, 50÷2=25 r 0, 25÷2=12 r 1, 12÷2=6 r 0, 6÷2=3 r 0, 3÷2=1 r 1, 1÷2=0 r 1. Reading the remainders bottom-to-top gives 11001000, the same answer. Use whichever method you find more reliable under exam pressure; the subtraction method is usually faster for 8-bit values because the place values are easy to recall.
Add the place values wherever there is a 1.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
128+64+8+2=202
So 110010102=20210.
A few patterns are worth committing to memory because they make conversions and sanity-checks instant:
These shortcuts are not a substitute for showing working, but they let you spot an obviously wrong answer before you write it down.
Hexadecimal needs 16 distinct digits, but denary only supplies ten symbols (0-9). The letters A-F fill the gap, representing the values 10-15. Crucially, every hex digit corresponds to exactly one nibble (4 bits), which is what makes hex and binary inter-convertible by inspection.
Why exactly one nibble? A single hex digit can take 16 different values, and a group of 4 bits can also take 24=16 different values. Because the two ranges are identical, there is a perfect one-to-one correspondence: every 4-bit pattern maps to exactly one hex digit and vice versa, with none left over. This is not true of denary — a denary digit has only 10 values, which does not line up with any whole number of bits — and it is the deep reason hex, rather than denary, is the notation of choice for displaying raw binary. Octal (base 8) has the same nice property at 3 bits per digit (23=8), but a nibble is a more convenient unit because two nibbles make a byte.
| Hex | Denary | Binary (nibble) | Hex | Denary | Binary (nibble) |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
The place values for a hex number are powers of 16:
1634096162256161161601
Split the binary number into nibbles of 4 bits starting from the right (pad the leftmost group with leading zeros if needed), then convert each nibble to its hex digit using the table above.
D1101 60110
110101102=D616
This is 9 bits, so it does not split evenly into nibbles. Pad on the left to 12 bits: 0001 0111 1100.
10001 70111 C1100
1011111002=17C16
Exam Tip: Always group from the right, then pad the left. Grouping from the left is the single most common cause of a wrong hex answer.
Convert each hex digit to its 4-bit binary equivalent and concatenate. Keep all four bits per digit — do not drop leading zeros inside the number.
3→0011,F→1111
3F16=001111112
Multiply each hex digit by its place value (a power of 16) and sum.
A16=10,716=7 (10×161)+(7×160)=160+7=167
(2×256)+(13×16)+(4×1)=512+208+4=724
This is the largest two-digit hex value and corresponds to a full byte of ones:
(15×16)+(15×1)=240+15=255
It is worth memorising the byte boundaries you will see constantly: 00 = 0, 0F = 15, 10 = 16, 80 = 128, FF = 255. Recognising these on sight makes reading colour codes and memory dumps almost instant — for example, you can tell at a glance that the colour #FF0000 is full-intensity red with no green or blue, without doing any arithmetic.
Two reliable methods exist. Repeated division by 16 reads remainders from bottom to top; alternatively, convert via binary (denary → binary → group into nibbles → hex), which many students find safer.
254÷16=15 remainder 14 15÷16=0 remainder 15
Reading remainders bottom-to-top: 15→F, then 14→E:
25410=FE16
70010=10101111002. Pad to 12 bits and group:
20010 B1011 C1100
70010=2BC16
Check: (2×256)+(11×16)+(12×1)=512+176+12=700. Correct.
To prove to yourself that the three systems are genuinely interchangeable, it helps to take one value all the way round. Start with the denary value 181 and convert it to binary, then to hex, then back to denary.
Denary → binary (subtraction method):
181−128=53,53−32=21,21−16=5,5−4=1,1−1=0
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
So 18110=101101012.
Binary → hex (group from the right into nibbles):
B1011 50101
So 101101012=B516.
Hex → denary (place values):
(11×16)+(5×1)=176+5=18110
We are back where we started, which confirms every step. Whenever you finish a conversion in the exam, doing even a partial reverse like this is the single most effective way to catch arithmetic slips. Note also how much shorter B5 is than 10110101 for exactly the same number — that compactness is the whole point of hexadecimal.
| Use Case | Example | Why hex? |
|---|---|---|
| Colour codes | #FF5733 (RGB) | Two hex digits per channel (red, green, blue), each holding 0-255 |
| MAC addresses | 00:1A:2B:3C:4D:5E | Six byte-pairs identify network hardware compactly |
| Memory addresses | 0x7FFF0000 | A 32-bit address fits in 8 readable digits |
| Error / status codes | 0x80070005 | Far easier to read and compare than 32 raw bits |
| Machine / assembly code | MOV AX, 0xFF | Compact, byte-aligned view of binary opcodes and operands |
| IPv6 addresses | 2001:0db8:85a3::8a2e | Hex groups separated by colons keep 128-bit addresses readable |
The unifying reason is always the same: one hex digit = one nibble, so hex is a compact, human-readable, lossless re-encoding of the underlying binary. Notice that hex never adds information or precision — a colour written as #FF5733 is byte-for-byte identical to its 24-bit binary form; hex just makes those 24 bits fit on one line and easy to copy. When an exam asks "why use hexadecimal", the answer is therefore never "to save memory" (it uses exactly the same bits) but always about human benefits: compactness, readability, fewer transcription errors, and trivial conversion to and from binary.
It also helps to see how these uses lean on the nibble correspondence in practice. A colour code such as #FF5733 is read in three byte-pairs — FF (red = 255), 57 (green = 87) and 33 (blue = 51) — each pair being exactly one 8-bit channel. A MAC address such as 00:1A:2B:3C:4D:5E is six bytes, one byte per pair, totalling 48 bits. A memory address such as 0x7FFF0000 is eight hex digits, exactly 32 bits, so you can tell its bit width just by counting characters. In every case the convention is the same: read hex in pairs, each pair is a byte, and you can drop straight to binary nibble-by-nibble whenever you need to inspect individual bits. This is why systems programmers, debuggers and network tools all default to hex: it is the most human-friendly view that still lines up cleanly with how data is actually laid out in memory.
Synoptic Links — Connects to:
binary-arithmetic(the unsigned ranges defined here are exactly the limits at which addition produces a carry-out and hence overflow).twos-complement-and-fixed-point(this lesson handles unsigned integers; two's complement reuses the same place-value machinery but redefines the most significant column as negative).character-encoding(ASCII/Unicode code points are quoted in hex, e.g.U+0041for 'A' = 65; the bits ↔ representable-values relationship is the same 2n idea).image-representation(24-bit RGB colour is three bytes, written as a 6-digit hex code — directly the colour-code use case above).- 1.1 Processor architecture — memory addresses on the address bus are quoted in hex; the number of address lines fixes how many distinct addresses (2n) can be reached, mirroring unsigned range here.
| Misconception | The correction |
|---|---|
| Grouping binary into nibbles from the left | Always group from the right; pad the leftmost nibble with leading zeros |
Dropping leading zeros inside a number (writing 3 as 11) | Each hex digit is exactly 4 bits: 0011, not 11 |
| Confusing hex letters with denary (treating B as 11 tens) | A=10 … F=15 are single digits, not two-digit numbers |
| Treating hex place values as powers of 8 | Hex is base 16: place values are 1,16,256,4096,… |
| Saying an n-bit value holds 2n different largest numbers | It holds 2n distinct values, the largest being 2n−1 (zero uses one pattern) |
| Believing hex is "what the computer uses" | The computer uses binary; hex is purely a human-facing notation |
Two of these deserve a little more discussion because they are where A-Level candidates most often quietly lose marks.
The off-by-one on range is subtle. It is tempting to say an 8-bit value "goes up to 256", but there are 256 patterns and they must cover the values 0 through 255 inclusive — 256 different values, the largest of which is 255. The clean way to express this in an answer is: "28=256 distinct values, range 0 to 28−1=255." Stating the formula 2n−1 explicitly almost always earns the justification mark, whereas writing just "0 to 255" leaves the examiner unsure whether you understand why.
The "hex saves memory" trap appears whenever a question asks for an advantage of hexadecimal. Because hex is a re-encoding of the very same bits, it stores no more and no less than the binary it represents — so any answer claiming a storage or efficiency benefit is wrong. The marks live entirely in the human advantages: a 32-bit address shown as 8 hex digits is far easier to read, write, compare and dictate than 32 binary digits, and converting back to binary is trivial because each digit is one nibble. Tie your advantage to readability and error-reduction, never to size.
A network engineer is reading raw memory contents and sees the byte B3 and the bit pattern 10010111. (Total: 8 marks)
(a) Convert B3 from hexadecimal to (i) binary and (ii) denary, showing your working. [3]
(b) Convert the bit pattern 10010111 to hexadecimal. [2]
(c) State the range of unsigned integers that can be stored in one byte, and explain why hexadecimal — rather than binary — is conventionally used to display memory contents. [3]
| Mark | AO | Awarded for |
|---|---|---|
| 1 | AO2 | (a)(i) Correct nibble expansion B → 1011 and 3 → 0011 |
| 2 | AO1 | (a)(ii) Correct hex place values used (16 and 1) |
| 3 | AO2 | (a)(ii) Correct denary value 179 |
| 4 | AO2 | (b) Correct grouping into 1001 and 0111 |
| 5 | AO2 | (b) Correct hex digits giving 97 |
| 6 | AO1 | (c) Stating the byte range 0 to 255 |
| 7 | AO1 | (c) Stating hex is a compact / readable representation |
| 8 | AO2 | (c) Justifying why — each hex digit maps to exactly one nibble (4 bits) |
AO split: AO1 = 3, AO2 = 5.
(a)(i) B is 1011 and 3 is 0011, so B3 = 10110011. (ii) B is 11 and that is in the 16s column, 3 is in the 1s column. 11×16=176 and 3×1=3, so 176+3=179. (b) Split 10010111 into 1001 and 0111. 1001 is 9 and 0111 is 7, so it is 97 in hex. (c) One byte can store 0 to 255. Hex is used because it is shorter than binary and easier to read.
Examiner-style commentary: Marks 1-6 are all secured — both conversions are correct and clearly worked, and the byte range is right. Mark 7 is given for "shorter and easier to read", but mark 8 is not awarded: the answer never explains the underlying reason (one hex digit = one nibble = 4 bits), so the justification is asserted rather than reasoned. Around 7/8.
(a)(i) Expanding each hex digit to a nibble: B →1011, 3 →0011, so B316=101100112. (ii) Using hex place values 161 and 160: (11×16)+(3×1)=176+3=17910; a quick check from the binary confirms 128+32+16+2+1=179. (b) Grouping the byte from the right into nibbles gives 1001 0111; 1001=9 and 0111=7, so 100101112=9716. (c) An unsigned byte stores 28=256 distinct values, i.e. 0 to 255 inclusive (the largest is 28−1=255 because one pattern is reserved for zero). Hexadecimal is preferred for memory dumps because each hex digit corresponds to exactly one nibble, so a full byte is exactly two hex digits. This makes the notation compact (8 bits shown as 2 characters), unambiguous, and trivially convertible back to binary by inspection — far less error-prone for a human than reading long strings of 1s and 0s, while losing no information.
Examiner-style commentary: All 8 marks secured. The discriminators that lift this above the mid-band answer are (i) the explicit 28−1 reasoning for why the maximum is 255, and (ii) mark 8 — the candidate gives the mechanism behind hex's readability (one digit ↔ one nibble, byte ↔ two hex digits), rather than merely asserting that it is "easier". The back-check in (a)(ii) is good exam discipline.
chmod 755). The same "group the bits" idea applies, just three at a time because 8=23. Seeing octal makes the general principle obvious: any base that is itself a power of 2 has a clean nibble-style grouping with binary.0100 0010). Investigate why this trades storage efficiency for easy human-readable display in calculators, tills and seven-segment displays, and why financial software sometimes prefers it to avoid the binary rounding errors you will meet in the floating-point lesson.Exam Tip: In every base-conversion question, show the working (place values, remainders, or nibble grouping) — method marks are available even if the final figure is wrong. Finish by converting your answer back to the original base as a 10-second self-check; it catches the majority of slips.
Exam Tip: Learn the powers of 2 up to 216 and the four-bit hex table cold. Almost every conversion in 1.4.1 — and many in image, sound and addressing questions later — is fast and accurate if these are automatic, and painfully slow if they are not.
Exam Tip: When you are asked to justify the use of hex, structure the answer as a contrast: "compared with binary, hex is far more compact and readable for a human, while still mapping one digit to one nibble so conversion is trivial and lossless." A contrastive sentence like this reliably hits the reasoning mark that a one-word answer misses.