Everything is a 1 or a 0
Computers don't understand words or pictures the way we do. Deep inside, they only understand two things: electricity flowing, or not flowing. We represent those two states as 1 and 0. That's binary.
Converting Denary to Binary
Denary is the number system you use every day. Base 10, digits 0 through 9. To convert a denary number to binary, we use the division by 2 method. Divide by 2, keep the remainder. Repeat until you reach 0. Read the remainders bottom to top.
Converting Binary to Denary
To convert binary back to denary, we use powers of 2. Each bit position has a value, starting from the right at 2¹⁰ = 1, doubling each time you move left. Click each bit that is a 1 to add its value to the total.
Hexadecimal
Binary is powerful but hard for humans to read. Imagine having to write 10101111 every time instead of AF. Hexadecimal is a base 16 number system that gives us a much shorter way to represent binary data, and computers use it everywhere.
Hexadecimal Conversions
Now that you know the 16 hex digits, let's learn how to convert between hexadecimal, denary and binary. There are four conversions to master. Watch each one, then try it yourself.
Binary Addition and Overflow
Adding binary numbers works the same way as adding denary numbers in columns. The difference is that in binary, there are only two digits — 0 and 1. So when you add 1 + 1, you cannot write 2 because 2 does not exist in binary. Instead you write 0 and carry 1 to the next column. There are only four rules to learn.
An 8-bit register can only hold 8 bits. The largest value it can store is 11111111 which is 255 in denary. When two numbers add up to more than 255, the result needs a 9th bit. That 9th bit gets cut off and the result stored in the register is wrong. This is called an overflow error.
Logical Binary Shifts
A binary shift moves every bit in a register left or right by a number of positions. Zeros fill in from the opposite end and any bits that fall off the edge are permanently lost. The most useful thing about shifts is what they do to the value stored — shifting left multiplies by 2 and shifting right divides by 2.
If a 1 bit falls off the end of the register it is gone. The value you get back is not double or half what you started with. It is just wrong. This is the same idea as overflow but caused by shifting rather than addition.
Two's Complement
Computers only store 0s and 1s. There is no minus sign in binary. Two's complement solves this by using the leftmost bit — the Most Significant Bit — as a sign bit. If the MSB is 0, the number is positive. If the MSB is 1, the number is negative. Everything else stays the same.
To convert a positive binary number to its negative two's complement form: flip every bit, then add 1. Two steps, every time, no exceptions.
In two's complement, the MSB has a negative weight of -128 instead of 128. Every other bit position stays the same. To find the value, add up all the positions where there is a 1 — but treat the MSB as -128.
How computers represent text
Look at the keyboard in front of you. Every key is a character. But when you press A, your computer does not receive the letter A. Your computer only understands one thing.
How computers represent sound
Sound is a wave. Your computer cannot store a wave directly because it only understands binary numbers. Instead, it takes snapshots of the wave at regular intervals and stores each snapshot as a binary number. This process is called sampling.
Sample rate is how many snapshots are taken per second. It is measured in Hertz (Hz) or kilohertz (kHz). The more samples taken per second, the more accurately the sound is recreated — but the larger the file becomes.
Sample resolution is how many bits are used to store each individual snapshot. More bits per sample means more possible values, which means a more accurate recording — and a bigger file.
Before calculating file sizes you need to know the storage units. Cambridge always uses 1024 — never 1000. Using 1000 in an exam will cost you marks.
| Unit | Abbreviation | Equal to |
|---|---|---|
| Bit | b | Smallest unit of data — a single 0 or 1 |
| Nibble | - | 4 bits |
| Byte | B | 8 bits |
| Kibibyte | KiB | 1,024 bytes |
| Mebibyte | MiB | 1,024 KiB |
| Gibibyte | GiB | 1,024 MiB |
| Tebibyte | TiB | 1,024 GiB |
| Pebibyte | PiB | 1,024 TiB |
| Exbibyte | EiB | 1,024 PiB |
The formula is: sample rate × sample resolution × duration. This gives you the size in bits. Then you convert down through the units.
A sound file is recorded at 22,050 Hz, with a sample resolution of 8 bits, for 20 seconds.
How computers represent images
Every image on a screen is made of tiny squares called pixels. Each pixel stores a colour value as a binary number. The quality of an image comes down to two things: how many pixels there are, and how many bits are used to store each one.
Resolution is the number of pixels in an image, given as width x height. A higher resolution means more pixels, a sharper image, and a larger file size.
Colour depth is the number of bits used to store each pixel's colour. More bits means more possible colour values, which means a more accurate image and a larger file.
The formula is: width × height × colour depth. This gives the file size in bits. Then convert using the same units as before.
An image is 1024 x 768 pixels with a colour depth of 16 bits.
Data Storage and Compression
Every time you upload a photo, send a file on WhatsApp, or submit work online, there is a size limit. Compression is how we reduce the size of a file so it fits within those limits. There are two types and they work in very different ways.
Lossy compression permanently removes data from a file to make it smaller. The quality of the file is reduced and the original cannot be recovered. It is used when a small reduction in quality is acceptable.
Lossless compression reduces file size without removing any data. The original file can be perfectly reconstructed from the compressed version. It is used when the exact original data must be preserved.
Run Length Encoding is a lossless compression algorithm Cambridge specifically asks about. Instead of storing every value individually, RLE stores how many times each value repeats in a row. A long sequence of the same value is replaced by just two pieces of information: the value and its count.
Quick Reference
Everything you need for Topic 1 in one place. Come back to this tab any time.
| Power | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
|---|---|---|---|---|---|---|---|---|
| Value | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| Denary | Binary | Hex |
|---|
| Denary | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |