1.2.3 Units
How big is a photo? How much music fits on a phone? To answer these questions you need to know the units that measure data, and how to calculate the size of a file.
Why data is stored in binary
A computer is built from circuits (switches) that are either on or off. These two states are easy to build, very fast, and very reliable. We write them as 1 (on) and 0 (off). So a computer stores all data (numbers, text, images and sound) as patterns of 1s and 0s, which is binary.
The units of data
All the other units are built up from the bit. In the exam, units go up in 1,000s.
| Unit | Size |
|---|---|
| Bit | 1 binary digit (0 or 1) |
| Nibble | 4 bits |
| Byte | 8 bits |
| Kilobyte (KB) | 1,000 bytes |
| Megabyte (MB) | 1,000 kilobytes |
| Gigabyte (GB) | 1,000 megabytes |
| Terabyte (TB) | 1,000 gigabytes |
| Petabyte (PB) | 1,000 terabytes |
Some systems use 1,024 instead of 1,000 for each step (because 1,024 is 2 to the power 10). The exam also accepts 1,024. This page uses 1,000, so use 1,000 unless the question tells you otherwise.
Converting between units
- •To go from a smaller unit to a bigger unit, divide by 1,000 for each step.
- •To go from a bigger unit to a smaller unit, multiply by 1,000 for each step.
MB to GB is going up one unit, so divide by 1,000.
4,500 / 1,000 = 4.5
Answer: 4.5 GB
Check: 4.5 GB x 1,000 = 4,500 MB.
TB to GB is down one unit: 2.5 x 1,000 = 2,500 GB.
GB to MB is down one more unit: 2,500 x 1,000 = 2,500,000 MB.
Answer: 2,500,000 MB
Check: 2,500,000 MB / 1,000 = 2,500 GB, and 2,500 GB / 1,000 = 2.5 TB.
Bits to bytes: 24,000 / 8 = 3,000 bytes.
Bytes to kilobytes: 3,000 / 1,000 = 3.
Answer: 3 KB
Check: 3 KB = 3,000 bytes, and 3,000 x 8 = 24,000 bits.
Capacity calculations
You may be asked how many files fit on a device, or how much space a set of files uses. Put everything in the same unit first. Then add or divide.
Total size of the photos: 40 x 5 = 200 MB.
Convert to GB: 200 / 1,000 = 0.2 GB.
Space left: 8 - 0.2 = 7.8 GB.
Answer: 7.8 GB
Check in MB: 8 GB = 8,000 MB. 8,000 - 200 = 7,800 MB = 7.8 GB.
2 GB = 2 x 1,000 = 2,000 MB.
Number of photos: 2,000 / 4 = 500.
Answer: 500 photos
Check: 500 x 4 MB = 2,000 MB = 2 GB.
File size formulas
You need three formulas. The answer is always in bits. Then convert to bytes (divide by 8), and then to KB or MB if you need to.
Image file size (bits) = colour depth (bits per pixel) x height (pixels) x width (pixels)
Text file size (bits) = bits per character x number of characters
The words mean:
- •Sample rate: the number of samples taken each second (measured in hertz, Hz). A bigger rate means a higher quality sound, and a bigger file.
- •Bit depth: the number of bits used for each sample.
- •Colour depth: the number of bits used for the colour of each pixel.
- •Resolution: the height and width of an image in pixels.
Sound
Samples: 8,000 x 10 = 80,000 samples.
Bits: 80,000 x 8 = 640,000 bits.
Bytes: 640,000 / 8 = 80,000 bytes.
Kilobytes: 80,000 / 1,000 = 80.
Answer: 80 KB
Check a different way: a bit depth of 8 is 1 byte per sample, so 80,000 samples is 80,000 bytes = 80 KB.
Image
Pixels: 100 x 50 = 5,000 pixels.
Bits: 5,000 x 8 = 40,000 bits.
Bytes: 40,000 / 8 = 5,000 bytes.
Kilobytes: 5,000 / 1,000 = 5.
Answer: 5 KB
Check a different way: 8 bits is 1 byte per pixel, so 5,000 pixels is 5,000 bytes = 5 KB.
Pixels: 1,000 x 500 = 500,000 pixels.
Bits: 500,000 x 24 = 12,000,000 bits.
Bytes: 12,000,000 / 8 = 1,500,000 bytes.
Megabytes: 1,500,000 / 1,000 / 1,000 = 1.5.
Answer: 1.5 MB
Check a different way: 24 bits is 3 bytes per pixel, so 500,000 x 3 = 1,500,000 bytes = 1.5 MB.
Text
Bits: 2,000 x 8 = 16,000 bits.
Bytes: 16,000 / 8 = 2,000 bytes.
Kilobytes: 2,000 / 1,000 = 2.
Answer: 2 KB
Check a different way: 8 bits is 1 byte per character, so 2,000 characters is 2,000 bytes = 2 KB.
Bits: 500 x 16 = 8,000 bits.
Bytes: 8,000 / 8 = 1,000 bytes.
Answer: 1,000 bytes
Check a different way: 16 bits is 2 bytes per character, so 500 x 2 = 1,000 bytes.
2. Put in the numbers (check the units: seconds, pixels, bits).
3. Multiply to get an answer in bits.
4. Divide by 8 for bytes, then by 1,000 for each step up to KB, MB or GB.
5. Check it a second way. For example, divide bits per sample by 8 first to get bytes per sample. The answer must match.
No calculator is allowed, so the numbers are chosen to work out by hand. Write each step down so you can pick up marks if one step goes wrong.
What changes the file size?
| If you... | The file size... |
|---|---|
| double the sample rate | doubles |
| double the duration of a sound | doubles |
| halve the bit depth | halves |
| double the colour depth | doubles |
| double the width and the height of an image | is 4 times bigger (2 x 2) |
A bigger file means more storage used and longer to send over a network. But it gives better quality: more detail in a sound or an image.
Metadata
Files also hold extra information about themselves, such as the image's height and width, the date it was made and the file type. This is called metadata. It makes a real file slightly bigger than the formula gives. In the exam, you may be told to ignore it. Or you may be told to allow a number of bytes for it.
Text: 2,000 x 8 = 16,000 bits = 2,000 bytes.
Total: 2,000 + 500 = 2,500 bytes = 2.5 KB.
Answer: 2,500 bytes (2.5 KB)
Exam technique
- •State questions need one fact, such as "a byte is 8 bits".
- •Convert and calculate questions need working. Show every step. Most of the marks are for the method.
- •Always give the unit with your answer.
- •For explain questions on binary, say that computers are made of circuits with two states (on and off), so only two digits can be used.
- •Write the formula first. This often earns the method mark.