Why binary?
Computers are built from transistors that are either on or off, so they can only reliably store two states: 1 and 0. This is called binary (base 2). Everything a computer stores, text, numbers, images, sound, is ultimately just patterns of binary digits (bits).
Bits, nibbles, bytes
- A bit is a single 0 or 1.
- A nibble is 4 bits.
- A byte is 8 bits, and can represent 256 different values (0 to 255).
- Storage units scale up in multiples of 1024 for the exam: 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB, 1 TB = 1024 GB.
Binary to denary (and back)
Each bit position in an 8-bit binary number is worth a power of 2, reading left to right: 128, 64, 32, 16, 8, 4, 2, 1. To convert binary to denary, add up the place values where there is a 1. To convert denary to binary, subtract the largest place value that fits, repeatedly, marking 1s and 0s as you go.
Binary addition and overflow
Add binary numbers column by column like normal addition, carrying when a column totals 2 or more (1+1=10, carry the 1). If an 8-bit register cannot hold the result of an addition, this is called overflow, and it causes an error because the number is too big to store.
Hexadecimal
Hexadecimal (base 16) uses digits 0 to 9 then A to F (A=10 up to F=15). It is used because it is a much shorter way of representing binary, one hex digit exactly represents one nibble (4 bits), so a byte is always 2 hex digits. Hex is used for MAC addresses, colour codes (like #FF0000), and memory addresses because it is easier for humans to read than long strings of 1s and 0s.
Character encoding
Characters are stored using a code that maps each character to a binary number. ASCII uses 7 or 8 bits, giving 128 or 256 possible characters, enough for English letters, numbers and symbols. Unicode uses more bits (commonly 16), allowing over 100,000 characters, so it can represent every language and symbol in the world, including emoji.
Images
A bitmap image is stored as a grid of pixels. Each pixel's colour is stored as a binary number. Colour depth (bits per pixel) determines how many colours are possible, more bits means more colours but a bigger file. Resolution (the number of pixels) also affects file size and image quality, higher resolution means more pixels and a larger file.
Sound
Sound is analogue in the real world, so it must be sampled to be stored digitally. Sample rate is how many samples are taken per second (measured in Hz). Bit depth is how many bits are used to store each sample. Higher sample rate and higher bit depth both improve sound quality but increase file size.
Common mistakes
- Forgetting binary place values start at 128 for 8 bits, not 256.
- Mixing up bits and bytes (8 bits = 1 byte).
- Forgetting each hex digit maps to exactly a nibble.
- Confusing sample rate (samples per second) with bit depth (bits per sample).
How many bits are in a byte?
8 bits.
tap to reveal
How many different values can a single byte store?
256 (0 to 255).
tap to reveal
What are the place values for an 8-bit binary number, left to right?
128, 64, 32, 16, 8, 4, 2, 1.
tap to reveal
Convert the binary number 10110101 to denary.
128+32+16+4+1 = 181.
tap to reveal
What is overflow in binary addition?
When the result of an addition is too big to fit in the number of bits available, causing an error.
tap to reveal
What base is hexadecimal, and what digits does it use?
Base 16, using digits 0-9 then A-F, where A=10 and F=15.
tap to reveal
How many bits does one hexadecimal digit represent?
4 bits (a nibble).
tap to reveal
Why is hexadecimal used instead of binary in things like colour codes and MAC addresses?
It is much shorter and easier for humans to read than long strings of 1s and 0s, while still mapping exactly onto binary.
tap to reveal
What is the difference between ASCII and Unicode?
ASCII uses 7 or 8 bits for up to 256 characters (mainly English); Unicode uses more bits (commonly 16) to represent over 100,000 characters from all languages and symbols.
tap to reveal
What two factors affect the file size and quality of a bitmap image?
Resolution (number of pixels) and colour depth (bits per pixel).
tap to reveal
What is sample rate in digital sound?
The number of samples taken per second, measured in Hz.
tap to reveal
What is bit depth in digital sound?
The number of bits used to store each sample; higher bit depth means better quality but larger file size.
tap to reveal
How many bytes are in 1 KB, and 1 KB in 1 MB, for exam purposes?
1 KB = 1024 bytes, and 1 MB = 1024 KB.
tap to reveal
What is a nibble?
4 bits, half of a byte.
tap to reveal
Why do computers use binary rather than denary?
Because they are built from transistors that can only reliably represent two states, on (1) and off (0).
tap to reveal