1.1 Number Systems
A computer stores everything as binary because a circuit has two reliable states: on (1) and off (0). Every number, character, picture and sound is converted into a pattern of bits before the computer can process it.
| Term | Meaning |
|---|---|
| Bit | A single binary digit, 0 or 1 |
| Nibble | 4 bits |
| Byte | 8 bits |
| Kilobyte (KB) | 1000 bytes (1024 bytes when using KiB) |
| Megabyte (MB) | 1000 KB |
| Gigabyte (GB) | 1000 MB |
| Terabyte (TB) | 1000 GB |
Denary to binary (and back)
Use the place values 128, 64, 32, 16, 8, 4, 2, 1 for an 8-bit byte. To convert denary to binary, subtract the largest place value that fits and repeat, writing 1 where you used a value and 0 where you did not.
To convert binary to denary, add the place values wherever a 1 appears. To convert binary to hexadecimal, split the byte into two nibbles and convert each nibble separately (1011 0111 → B7). Hexadecimal is used because it is far shorter than binary for humans to read and write, and converting between hex and binary is trivial.
Binary addition and overflow
Add column by column from the right using four rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).
Overflow happens when the result of an addition is too large to be stored in the number of bits available — for example, adding two 8-bit numbers and getting a 9-bit answer. The extra carry bit is lost, so the stored answer is wrong. The computer must detect the overflow so it can report an error.
Logical binary shifts
A logical left shift moves every bit one place to the left and puts a 0 in the empty right-hand position; this multiplies the value by 2. A logical right shift moves bits right and puts a 0 in the empty left-hand position, dividing by 2. Bits shifted off the end are lost.
Two's complement (negative numbers)
In an 8-bit two's complement system the leftmost bit has a place value of −128. To write a negative number, write the positive value in binary, invert every bit, then add 1.
1.2 Text, Sound and Images
Character sets
| Character set | Description |
|---|---|
| ASCII | 7-bit code giving 128 characters; extended ASCII uses 8 bits for 256 characters. Covers English letters, digits and punctuation only. |
| Unicode | Uses up to 4 bytes per character and can represent virtually every language, symbol and emoji. Needed for global communication and so that one file works on any computer. |
Representing sound
A microphone converts the analogue sound wave into an electrical signal, which is sampled at regular intervals. Each sample is stored as a binary number.
- Sample rate — the number of samples taken per second, in hertz (Hz). A higher sample rate captures the wave more accurately and gives a larger file.
- Sample resolution (bit depth) — the number of bits used for each sample. More bits means more possible values, so amplitude is recorded more precisely, again giving a larger file.
Representing images
A bitmap image is a grid of pixels. Each pixel stores a binary value that refers to a colour in a palette.
- Resolution — the number of pixels in the image (width × height). Higher resolution gives a sharper image but a bigger file.
- Colour depth — the number of bits per pixel. 1 bit = 2 colours, 4 bits = 16 colours, 8 bits = 256 colours, 24 bits = 16.7 million colours.
- Metadata — data stored in the file about the image itself: dimensions, colour depth, resolution, date created, camera settings. It is not part of the picture.
1.3 Data Storage
| Storage type | How it works | Typical use |
|---|---|---|
| Magnetic (HDD) | Magnetised areas on a spinning platter read by a moving head | Large capacity, low cost per GB; desktops, servers, backups |
| Optical (CD/DVD/Blu-ray) | A laser burns pits and lands; a laser reads the reflections | Music, films, software distribution; cheap but low capacity |
| Solid state (SSD, flash, SD card) | Floating-gate transistors hold charge; no moving parts | Laptops, phones, cameras; fast, silent, shock resistant, more expensive per GB |
Secondary storage is needed because RAM is volatile and limited: it stores the operating system, applications, user files and backups permanently. Virtual memory is an area of secondary storage used as an extension of RAM when RAM is full; pages of data are swapped between RAM and disk, which is much slower than RAM.
1.4 Compression
| Type | How it works | Effect |
|---|---|---|
| Lossy | Permanently removes data the human eye or ear is unlikely to notice (MP3, JPEG) | Much smaller files, but quality is reduced and cannot be restored |
| Lossless | Stores the data more efficiently so the original can be rebuilt exactly (PNG, FLAC, ZIP) | Smaller files with no loss of quality, but less reduction than lossy |
Run-length encoding (RLE) is a lossless method that stores a repeated value once, followed by how many times it occurs: WWWWWBBBWW becomes 5W3B2W. It works best on data with long runs of identical values, such as simple logos.
Exam trap
File size questions are easy marks — but only if you keep the units straight. Multiply first, then divide by 8 to go from bits to bytes, and by 1000 (or 1024) to reach KB. Always state the unit.
Five-minute drill
- Convert 173 to 8-bit binary and to hexadecimal.
- Add 0110 1100 and 0011 0110. State whether overflow occurs.
- Left shift 0000 0110 twice. What is the denary result?
- A 4-minute stereo recording is sampled at 20 kHz with a resolution of 8 bits. Calculate the file size in MB.
- Explain why Unicode is preferred to ASCII for a website used worldwide.
A photograph is 4000 pixels wide and 3000 pixels high and uses a colour depth of 24 bits. (a) Calculate the file size in megabytes. Show your working. (b) The photograph is saved as a JPEG instead of a PNG. Explain one effect this has on the file.
- (a) 4000 × 3000 × 24 = 288 000 000 bits (1); ÷ 8 = 36 000 000 bytes (1); ÷ 1 000 000 = 36 MB (1).
- (b) JPEG uses lossy compression, so data is permanently removed (1); the file is much smaller but quality is reduced and cannot be restored (1).
A computer stores the denary value −6 using 8-bit two's complement. (a) Write the binary representation. (b) State the range of values that can be stored in 8 bits using two's complement. (c) Explain what is meant by overflow.
- (a) +6 = 0000 0110; invert = 1111 1001; add 1 = 1111 1010 (2 marks for the answer, 1 for method).
- (b) −128 to +127 (1).
- (c) The result of a calculation is larger than the maximum value that can be held in the available number of bits (1), so the most significant bit is lost and the stored answer is incorrect (1).