Study notes
Number Systems
How computers count in binary (base 2) and hexadecimal (base 16), and how to convert to and from our everyday denary (base 10).
Learn it step by step
Computers count in binary (base 2)
A computer only has two states: off (0) and on (1). Each digit is a bit. Unlike denary (base 10), each column is worth twice the one on its right.
| Place value | 8 | 4 | 2 | 1 |
|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 0 |
Binary to denary: add the ON place values
Write the place values (…16, 8, 4, 2, 1) above each bit, then add the values where the bit is 1.
| 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 |
Hexadecimal (base 16): shorthand for binary
Hex uses 16 digits: 0-9 then A-F (A=10 … F=15). One hex digit packs exactly 4 bits, so long binary numbers become short and readable.
| Denary | Binary | Hex |
|---|---|---|
| 10 | 1010 | A |
| 12 | 1100 | C |
| 15 | 1111 | F |
Why programmers use hex
Colours (#FF8800), memory addresses and error codes are written in hex because it is far easier to read than a long string of 0s and 1s, while still mapping cleanly onto the binary the machine uses.
Worked examples
Convert the binary number 1101 to denary.
- Place values: 8, 4, 2, 1
- Bits: 1, 1, 0, 1 -> ON at 8, 4 and 1
- 8 + 4 + 0 + 1 = 13
Convert the denary number 45 to binary.
- Largest place value <= 45 is 32; 45 - 32 = 13
- 13: take 8 (13 - 8 = 5), take 4 (5 - 4 = 1), take 1
- Fill 1s at 32, 8, 4, 1 -> 101101
Convert the hexadecimal 2F to denary.
- 2F: the 2 is the 16s column, F is the 1s column
- F = 15
- (2 x 16) + 15 = 32 + 15 = 47
Mind map
Mind map for Number Systems.
- Binary (base 2)
- bits: 0 or 1
- each column doubles
- Denary (base 10)
- our everyday digits 0-9
- Hexadecimal (base 16)
- digits 0-9, A-F
- 1 hex digit = 4 bits
- Converting
- binary -> denary: add ON place values
- denary -> binary: subtract place values