OCR H446, section 1.4.1 (f)
You need to be able to convert positive integers between the three number bases, in any direction. There are six conversions, and the table shows the easiest method for each.
| From | To | Method |
|---|---|---|
| Binary | Denary | Add the place values where there is a 1 |
| Denary | Binary | Subtract place values, or divide by 2 |
| Binary | Hex | Split into groups of 4 bits, convert each |
| Hex | Binary | Replace each hex digit with its 4 bits |
| Hex | Denary | Multiply each digit by its place value (powers of 16) |
| Denary | Hex | Divide by 16 repeatedly, or go via binary |
The reference table for hex digits:
| Hex | Binary |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
Binary to denary
Add the place values wherever there is a 1.
Denary to binary
Subtracting place values (8 bits: 128, 64, 32, 16, 8, 4, 2, 1). For 150:
- 128 fits (22 left): 1
- 64 doesn't: 0
- 32 doesn't: 0
- 16 fits (6 left): 1
- 8 doesn't: 0
- 4 fits (2 left): 1
- 2 fits (0 left): 1
- 1 doesn't: 0
Or divide by 2 and read the remainders from the bottom up (see 1.4.1 (b)).
Binary to hexadecimal
Group the bits into fours, starting from the right, adding leading zeros if needed. Convert each group to one hex digit.
For a longer number: . Group from the right: . Pad the first group: .
Hexadecimal to binary
Replace each hex digit with its 4-bit pattern.
Hexadecimal to denary
Multiply each digit by its place value (, , , ) and add.
Denary to hexadecimal
Method 1: divide by 16
Divide by 16 repeatedly, and read the remainders from the bottom up (turning remainders 10 to 15 into A to F).
Convert 500.
| Divide | Quotient | Remainder |
|---|---|---|
| 31 | 4 | |
| 1 | 15 (F) | |
| 0 | 1 |
Reading upwards: .
Check: . ✓
Method 2: go via binary
Convert to binary first, then group in fours.
A full chain of conversions
Convert to all three bases.
- Denary: .
- Hex: , so .
- Check the hex: . ✓
Common mistakes
- Grouping the binary from the left instead of the right (for numbers that aren't a multiple of 4 bits).
- Reading the division remainders top to bottom instead of bottom to top.
- Forgetting that A to F are 10 to 15.
- Writing the wrong number of bits: pad with leading zeros to the length asked for.
Worked example
Task: a memory address is . Give it in binary and in denary.
- Binary: , , , so .
- Denary: .
- Check from binary: . ✓
Exam tip: show the working (place values, groups of four, or the division table), and check by converting back. Remember that hex and binary convert directly in groups of 4 bits, so use that instead of going through denary.
Check yourself
Convert to binary
and , so .
Convert to hexadecimal
.
Convert 255 to hexadecimal
remainder 15, so .
Convert to denary
.