Number bases: binary, denary and hexadecimal
A-Level Computer Science · Data Representation: Number Bases, Binary Arithmetic and Character Sets
Place value is the whole idea
In any base, each column is the base times the column to its right. In binary the columns are $128, 64, 32, 16, 8, 4, 2, 1$. To read a binary number, add the column values wherever there is a $1$. There is nothing to memorise beyond the doubling.
Denary to binary
Work from the left: take the largest column that fits, subtract, repeat. For $180$: $128$ fits (leaves $52$), $64$ does not, $32$ fits (leaves $20$), $16$ fits (leaves $4$), $8$ does not, $4$ fits (leaves $0$). Result $10110100$. This is more reliable under exam pressure than repeated division.
Hexadecimal is just grouped binary
Each hex digit is exactly four bits, so conversion is done by splitting into nibbles: $1011\,0100 \to B\,4 \to$ $\text{B4}$. That is why hex exists — it makes long binary readable without changing the value. Never convert binary$\to$denary$\to$hex; go straight through nibbles.
Why programmers use hex
Colour codes, memory addresses and MAC addresses are all hex because one hex digit replaces four bits, so a $32$-bit address becomes eight readable characters instead of thirty-two.
Worked example: three-way conversion and cross-checking
An $8$-bit register holds the hex value $\text{9C}$.
(a) Write the value in binary. (b) Write it in decimal. (c) Check your result using a different route.
Solution
(a) Split each hex digit into four bits: $9 = 1001$, $\text{C} = 1100$. Put them together: $10011100$.
(b) Add the values of the columns that hold a $1$ bit: $128 + 16 + 8 + 4 = 156$.
(c) A different check: compute directly from the hex: $9 \times 16 + 12 = 144 + 12 = 156$ ✓. Two different routes give the same number, so you can be confident.
Exam tip: always check by order of magnitude. An $8$-bit number lies between $0$ and $255$; if you get $1560$, you have certainly misplaced a column somewhere.