File-Size Calculations
For GCSE Computer Science you need to calculate the size of various types of file - text, image and sound.
File Contents
Before you think about calculating the size of the file, it's helpful to think about the contents of the file represent:
- in a text file, each character in the text is stored either as an ASCII code (one byte) or as Unicode (four bytes).
- a bitmap image file contains numbers that represent the colour of each of the pixels, using a given number of bits (called the colour depth)
- when sound is recorded a measurement (called a sample) of the waveform is taken regularly at a fixed interval (called the sampling frequency (or "rate")) and stored as a number using a given number of bits (called the bit depth or sometimes the sample size
Note that metadata in image and sound files will add to the size, but possibly not as much as you've been told.
Calculations
What will affect the size of the file?
- text: the number of characters and the type of encoding. Multiply the number of characters by one for ASCII and four for Unicode.
- bitmap images: the size will be the number of pixels multiplied by the number of bits required for each pixel. The number of pixels is proportional to the area of the image, so is the width of the image multiplied by the height (just like the area of a rectangle in Maths).
- wave sounds: the size will be the number of samples multiplied by the the number of bits used by each sample. The number of samples can be calculated by multiplying the sampling frequency by duration of the recording in seconds. In practice, sound files tend to be stereo, so we would double this, but I've never seen the need for that in a GCSE exam.
The short answer is that you just multiply all the numbers together together - but it's better to understand why that works. Just be careful to check which units are expected.
Questions
Type your answers into the boxes and click the Check button to see whether they are correct. You will not be able to use a calculator in the GCSE exam, but you can here because the numbers might be bigger.