How do computers represent numbers in binary and hexadecimal, and how do we convert between bases reliably?
Convert whole numbers between binary, denary and hexadecimal, and perform binary addition, explaining the role of place value and overflow
A focused answer to the H2 Computing outcome on number bases. Place value in binary and hexadecimal, conversion methods between binary, denary and hexadecimal, binary addition, and the meaning of overflow.
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
SEAB wants you to convert whole numbers fluently between binary (base 2), denary (base 10) and hexadecimal (base 16), to add binary numbers showing carries, and to explain place value and overflow. The central idea is that every base uses the same positional rule - each column is the base raised to a power - so conversion is just a change of which powers you count in.
The answer
Place value in any base
In any base , the digit in the column places from the right is worth that digit times . In binary the columns are powers of two:
So . In hexadecimal the columns are powers of sixteen, and the digits run to then to for the values ten to fifteen.
Denary to binary
Two reliable methods:
- Subtract descending powers of two. Write the place values . For the number, put a under the largest power that fits, subtract it, and repeat with the remainder.
- Repeated division by 2. Divide the number by 2, recording remainders. The remainders read bottom-to-top give the binary digits.
Binary to hexadecimal and back
Because , one hex digit equals exactly four binary bits (a nibble). To go binary to hex, group the bits into nibbles from the right (pad the left with zeros) and convert each nibble. To go hex to binary, expand each hex digit to its four-bit pattern.
binary: 1101 0110
hex: D 6 -> 0xD6
Binary addition
Add column by column from the right, exactly like denary but carrying whenever a column reaches 2:
0 + 0 = 0
0 + 1 = 1
1 + 1 = 10 (write 0, carry 1)
1 + 1 + 1 = 11 (write 1, carry 1)
Overflow
A fixed-width register can only hold so many bits. If an addition produces a carry out of the most significant bit that there is no column to hold, the result is wrong - this is overflow. For an unsigned -bit number the range is to ; a result beyond it overflows.
Examples in context
Example 1. Colour codes on the web. A web colour like #1E90FF is three pairs of hex digits giving the red, green and blue intensities. Each pair is one byte (eight bits), so 1E is , 90 is and FF is . Reading colours in hex is exactly the nibble-grouping trick applied to bytes.
Example 2. Memory addresses. Debuggers print addresses such as 0x7FFE because hex packs a 16-bit address into four readable digits. An engineer reading 0xFF instantly knows all eight bits of that byte are set, which would be tedious to see in raw binary.
Try this
Q1. Convert to denary. [2 marks]
- Cue. so the high nibble is , and adds , giving .
Q2. Convert to 8-bit binary. [2 marks]
- Cue. .
Q3. Add and and state the result in binary. [2 marks]
- Cue. ; the run of ones rolls over with carries to set the next bit.
Exam-style practice questions
Practice questions written in the style of SEAB exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Original5 marks(a) Convert the denary number to 8-bit binary. (b) Convert your binary answer to hexadecimal. (c) State why hexadecimal is convenient for writing binary values.Show worked answer →
(a) Use repeated division by 2, or subtract descending powers of two. The place values are . We have , so the bits set are at :
128 64 32 16 8 4 2 1
1 1 0 1 1 0 0 1
So .
(b) Group the 8 bits into two nibbles of 4 bits: and . and . So .
(c) Each hexadecimal digit maps to exactly four binary bits, so a long binary string compresses to a quarter of the digits and is far easier to read and transcribe without error.
Markers reward the correct place-value working, the nibble grouping for hex, and a clear reason (one hex digit equals four bits).
Original4 marksAdd the 8-bit binary numbers and . Show your carries, give the 8-bit result, and state whether overflow has occurred if these are treated as unsigned 8-bit integers.Show worked answer →
Add bit by bit from the right, carrying where a column sums to 2 or 3:
carries: 1 1 1 1 1 0 0
0 1 1 0 1 1 1 0
+ 0 1 0 1 1 0 1 0
-----------------
1 1 0 0 1 0 0 0
The result is . In denary, and , and , which checks.
An unsigned 8-bit number can hold to . Since and there is no carry out of the most significant bit (the leftmost column), there is no overflow.
Markers reward correct carry propagation, the 8-bit result, and the overflow test (a carry out of the top bit, or a result exceeding the range).
Related dot points
- Represent signed integers using two's complement, convert to and from denary, and perform subtraction by addition, explaining range and overflow
A focused answer to the H2 Computing outcome on signed integers. Two's complement encoding, converting to and from denary, subtraction as addition, the representable range, and detecting signed overflow.
- Explain floating-point representation in terms of sign, mantissa and exponent, and discuss precision, range and rounding error
A focused answer to the H2 Computing outcome on floating point. The sign, mantissa and exponent fields, normalisation, the trade-off between precision and range, and why rounding errors arise.
- Explain how characters are encoded using ASCII and Unicode, including code points and UTF-8, and the implications for storage and internationalisation
A focused answer to the H2 Computing outcome on character encoding. ASCII and its limits, Unicode code points, the UTF-8 variable-length scheme, and the implications for storage and supporting many languages.
- Apply bitwise AND, OR, XOR, NOT and shift operations, and use masks to set, clear, toggle and test individual bits
A focused answer to the H2 Computing outcome on bitwise operations. The AND, OR, XOR and NOT operators, left and right shifts, and using masks to set, clear, toggle and test individual bits.
- Construct and interpret logic gates and truth tables, write Boolean expressions, and simplify them using Boolean algebra laws
A focused answer to the H2 Computing outcome on digital logic. The AND, OR, NOT, NAND, NOR and XOR gates, building and reading truth tables, writing Boolean expressions, and simplifying them with Boolean algebra laws and De Morgan.