A number system 数制 is a way of writing numbers using a fixed set of digits. You need three of them.
| System |
Base |
Digits used |
| Denary |
10 |
0–9 |
| Binary |
2 |
0 and 1 |
| Hexadecimal |
16 |
0–9 then A–F |
- denary 十进制 is the normal counting system (also called decimal).
- binary uses only 0 and 1.
- hexadecimal 十六进制 (hex) uses sixteen digits: 0–9, then A, B, C, D, E, F stand for 10, 11, 12, 13, 14, 15.
The base 基数 tells you how many different digits a system uses.
Place value
Each column in a number has a place value 位值. In binary the place values double from right to left. For an 8-bit number they are:
128 64 32 16 8 4 2 1
An 8-bit place-value chart: the 1s sit under the values that add up to 150
One bit 位 is a single 0 or 1. Eight bits make one byte 字节. Four bits (half a byte) is a nibble 半字节.
Converting between number systems
Denary → binary. Write the place values. Put a 1 under each value you need so they add up to your number; put 0 under the rest.
Example: change denary 150 to binary. $150 = 128 + 16 + 4 + 2$.
128 64 32 16 8 4 2 1
1 0 0 1 0 1 1 0
So $150$ = 10010110.
Binary → denary. Add the place values where there is a 1. 10010110 $= 128 + 16 + 4 + 2 = 150$.
Hexadecimal → binary. Change each hex digit into its own 4-bit group (a nibble).
Example: hex F08. $F = 1111$, $0 = 0000$, $8 = 1000$, so F08 = 1111 0000 1000.
Each hex digit maps to its own 4-bit nibble — F08 = 1111 0000 1000
Binary → hexadecimal. Group the bits into nibbles of 4, starting from the right. Change each nibble to one hex digit.
Denary → hexadecimal. The easy way is to change to binary first, then binary to hex.
This table helps with the hex letters:
| Denary |
Binary |
Hex |
| 10 |
1010 |
A |
| 11 |
1011 |
B |
| 12 |
1100 |
C |
| 13 |
1101 |
D |
| 14 |
1110 |
E |
| 15 |
1111 |
F |
Cambridge questions use binary numbers up to 16 bits long.
Why hexadecimal is used
Hex is shorter than binary and easier for people to read and write. One hex digit replaces 4 binary digits, so you make fewer mistakes. The value does not change — hex is just a shorter way to show the same binary.
Computer scientists use hex for:
- MAC addresses and IPv6 addresses
- colour codes in HTML (for example
#FF0000 is red)
- memory addresses 内存地址 and error codes
- showing the contents of memory (a "memory dump")