The units of data storage
Moving between units: multiply by 1,000 to go down the list, divide by 1,000 to go up. The two smallest steps are the exceptions — 8 bits make a byte, and 4 bits make a nibble.
Why data must be converted into binary to be processed. A computer is built from switches — transistors — and a switch has two states: on and off. There is no reliable way to build a component with ten distinguishable states, but two is easy and robust. So every value a computer handles, whether a number, a letter, a colour or a sound sample, has to be represented as a pattern of on and off states, which we write as 1s and 0s.
That is also why storage devices have fixed capacities: a device has a certain number of storage locations, each holding one bit, and no amount of software can create more.
- Bit
- a single binary digit, 0 or 1, representing one switch that is off or on
- Nibble
- 4 bits, or half a byte
- Byte
- 8 bits, the unit one character is usually stored in
Calculating file sizes
Three formulae are given in the specification and must be applied:
sound file size = sample rate × duration (s) × bit depth image file size = colour depth × image height (px) × image width (px) text file size = bits per character × number of characters
All three give an answer in bits. Almost every question then wants the answer in bytes, kilobytes or megabytes — so the conversion at the end is part of the calculation, not an optional extra.
Worked example
A sound file is recorded for 30 seconds at a sample rate of 44,100 Hz with a bit depth of 16. Calculate the file size in megabytes.
- Use the formula: sample rate × duration × bit depth.
- 44,100 × 30 × 16 = 21,168,000 bits.
- Convert to bytes by dividing by 8: 21,168,000 ÷ 8 = 2,646,000 bytes.
- Convert to kilobytes: 2,646,000 ÷ 1,000 = 2,646 KB.
- Convert to megabytes: 2,646 ÷ 1,000 = 2.646 MB.
Answer: About 2.65 MB. Show the unit at each conversion — marks are given for the method as well as the final figure.
Worked example
An image is 800 pixels wide and 600 pixels high with a colour depth of 24 bits. Calculate the file size in kilobytes.
- Use the formula: colour depth × height × width.
- 24 × 600 × 800 = 11,520,000 bits.
- Divide by 8 for bytes: 1,440,000 bytes.
- Divide by 1,000 for kilobytes: 1,440 KB.
- Note that metadata would add a little more, though an allowance for it is optional.
Answer: 1,440 KB, or about 1.44 MB.
Calculating required storage capacity for a set of files is the same skill applied more than once: work out each file size, add them together, and convert to a sensible unit. Watch for questions that give a number of identical files — the size of one multiplied by how many — or that ask how many files will fit on a device, which is the device capacity divided by the file size.
Common mistake
All three formulae give bits, not bytes. Dividing by 8 is the step most often forgotten, and it makes the answer eight times too large.
Before you practise
- Bit, nibble (4 bits), byte (8 bits), then kilobyte, megabyte, gigabyte, terabyte, petabyte — each 1,000 of the one before.
- Using 1,024 for conversions is also acceptable.
- Data must be binary because computers are built from switches with two states.
- sound file size = sample rate × duration × bit depth.
- image file size = colour depth × height × width.
- text file size = bits per character × number of characters.
- All three give bits — divide by 8 for bytes, then by 1,000 for each step up.
- For a set of files, calculate each and add; to find how many fit, divide capacity by file size.