Syllabus: Computer Science
1Data representation
2Data transmission
3Hardware
4Software
5The internet and its uses
6Automated and emerging technologies
7Algorithm design and problem-solving
8Programming
Number systems
Binary, denary and hexadecimal, converting between them, binary addition, overflow, logical shifts and two's complement.
Why computers use binary
A computer is built from billions of tiny switches. Each switch is either off or on, so the simplest number system for a computer has just two digits: 0 and 1. This is called binary.
Humans usually count in denary (base 10, digits 0 to 9). Programmers also use hexadecimal (base 16) because it is a short way to write long binary numbers.
| System | Base | Digits used |
|---|---|---|
| Binary | 2 | 0, 1 |
| Denary | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9 and A to F |
Binary place values
Each binary digit (bit) has a place value that doubles as you move left.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
Worked example: binary to denary
Add the place values that have a 1:
64 + 16 + 8 + 2 + 1 = 91
Worked example: denary to binary
Convert 45. Find which place values add up to 45:
32 + 8 + 4 + 1 = 45, so the binary number is 00101101.
Hexadecimal in one minute
One hex digit stands for exactly four bits, so split a binary number into groups of four:
0101 1011
5 B -> 5BSo binary 01011011 is 5B in hexadecimal, which is 91 in denary.
Try it yourself
- 1Convert 10110 from binary to denary.
- 2Convert 58 from denary to 8-bit binary.
- 3Convert 11110000 to hexadecimal.
Answers: 1) 22 2) 00111010 3) F0