2.3.1 - Storage units and file-size calculations

2.3.1 - Storage units and file-size calculations

Storage labels such as KiB and MiB look deceptively similar, but each step changes by a factor of 1024. In this lesson, you will rank binary storage units, convert between them, and construct reliable expressions for capacity, image data and audio data without losing track of bits and bytes.

Binary storage units

A bit is one binary digit: 0 or 1. Larger storage amounts are built from bits and bytes.

UnitSymbol used hereExact relationship
bitbitone binary digit
nibble-4 bits
byteB8 bits
kibibyteKiB1024 B = 2^10 B
mebibyteMiB1024 KiB = 2^20 B
gibibyteGiB1024 MiB = 2^30 B
tebibyteTiB1024 GiB = 2^40 B

From smallest to largest, the order is:

bit < nibble < byte < KiB < MiB < GiB < TiB

B means byte, not bit. A nibble is 4 bits, so two nibbles make one byte.

The names kibi, mebi, gibi and tebi are IEC binary prefixes. They represent powers of 2. Decimal SI prefixes represent powers of 10, so they are different units:

Binary unit required hereDecimal unit it must not be confused with
1 KiB = 1024 B1 kB = 1000 B
1 MiB = 1,048,576 B1 MB = 1,000,000 B

For Pearson Edexcel storage expressions in this topic, use the IEC units and factors of 1024. Writing MB when the quantity is a mebibyte silently changes the value.

The i in KiB, MiB, GiB and TiB signals a binary prefix. Each adjacent binary-prefixed byte unit is 1024 times the one before it.

Converting between units

First identify the starting and target units. Moving one step towards a smaller binary-prefixed unit multiplies by 1024; moving one step towards a larger one divides by 1024.

DirectionOperation for each adjacent step
TiB -> GiB -> MiB -> KiB -> Bmultiply by 1024
B -> KiB -> MiB -> GiB -> TiBdivide by 1024

The bit-byte boundary follows a different relationship: multiply bytes by 8 to get bits, or divide bits by 8 to get bytes.

Worked example 1: MiB to KiB

Convert 6 MiB to KiB:

6 MiB x (1024 KiB / 1 MiB) = 6144 KiB

The MiB units cancel, leaving the requested KiB.

Worked example 2: bytes to MiB

Convert 4,194,304 B to MiB:

4,194,304 B x (1 KiB / 1024 B) x (1 MiB / 1024 KiB) = 4 MiB

There are two steps from bytes to mebibytes, so there are two divisions by 1024.

Worked example 3: bits to KiB

16,384 bits x (1 B / 8 bits) x (1 KiB / 1024 B) = 2 KiB

This conversion uses 8 first, then 1024. Using 1024 between bits and bytes would be incorrect.

Worked example 4: TiB to bytes

2 TiB x (1024 GiB / 1 TiB) x (1024 MiB / 1 GiB) x (1024 KiB / 1 MiB) x (1024 B / 1 KiB) = 2 x 1024^4 B

There are four steps from TiB to B. 1024^3 B is one gibibyte, not one tebibyte.

Building capacity expressions

A storage requirement often contains repeated items and some additional data. Build its structure before doing any arithmetic:

required capacity = (number of items x size per item) + additional data

Every term must use the same unit before it is added. Brackets make it clear which complete amount is being converted.

Worked example: required capacity

A weather station stores 48 log files of 12 KiB each and one index of 32 KiB. Construct an expression for the required capacity in bytes.

First combine the quantities in kibibytes:

((48 x 12) + 32) KiB

Then convert the whole amount to bytes:

((48 x 12) + 32) x 1024 B

This evaluates to 608 KiB, or 622,592 B. The equally valid expression
(48 x 12 x 1024) + (32 x 1024) B converts each contribution separately.

The reverse question asks how many equal files fit in a capacity:

number of files = available capacity / size per file

The units must match before dividing. For example, a 2 GiB space holding 8 MiB files gives:

(2 x 1024 MiB) / (8 MiB per file) = 256 files

If a question says Construct an expression, the correct expression is the result; evaluation is not required. If it says Calculate, show the conversion, evaluate it and include the requested unit.

Image file-size expressions

For an image, width multiplied by height gives the number of pixels:

pixel count = width in pixels x height in pixels

Colour depth is the number of bits used for each pixel. Therefore:

image data size in bits = width x height x colour depth

The result is in bits because pixel count x bits per pixel = bits. To express it in bytes, divide by 8. To express it in kibibytes, divide by 8 and then by 1024:

image data size in KiB = (width x height x colour depth) / (8 x 1024)

This expression covers the image data described by those variables. Include extra data only when a question supplies it.

If one image variable is missing, convert the known file size to bits and divide by the product of the other factors. Let S be the image data size in bits:

Missing valueExpression
width in pixelsS / (height x colour depth)
height in pixelsS / (width x colour depth)
colour depth in bits per pixelS / (width x height)

For example, a known size in KiB becomes S = size in KiB x 1024 x 8 bits before it is used in the table.

Worked example: calculate an image size

An image is 320 x 240 pixels and uses a colour depth of 16 bits per pixel.

size = (320 x 240 x 16) / (8 x 1024) KiB

size = 150 KiB

Width x height alone would give 76,800 pixels, not a file size. Multiplying by colour depth creates a bit total.

Faded example: find a missing colour depth

An image is 640 x 320 pixels and its image data is 300 KiB. To find colour depth, first turn the supplied file size into bits, then divide by the pixel count:

colour depth = (300 x 1024 x 8) / (640 x 320) bits per pixel

colour depth = 12 bits per pixel

Notice the direction of the factor of 8. The known file size starts in bytes and must become bits, so it is multiplied by 8.

Audio file-size expressions

For audio data, sample rate is measured in samples per second for each channel. Multiplying it by duration in seconds gives the samples per channel. Bit depth gives the bits used for each sample value.

audio data size in bits = sample rate x bit depth x duration x number of channels

A mono recording has 1 channel; a stereo recording has 2. If duration is supplied in minutes, include x 60 to convert it to seconds before using a sample rate measured per second.

To construct the size in mebibytes:

audio data size in MiB = (sample rate x bit depth x duration x channels) / (8 x 1024^2)

The division by 8 changes bits to bytes. The division by 1024^2 changes bytes to mebibytes.

If one audio variable is missing, convert the known file size to bits and divide by the product of the other three factors. Let S be the audio data size in bits:

Missing valueExpression
sample rateS / (bit depth x duration x channels)
bit depthS / (sample rate x duration x channels)
durationS / (sample rate x bit depth x channels)
number of channelsS / (sample rate x bit depth x duration)

A known size in MiB becomes S = size in MiB x 1024^2 x 8 bits before it is used in the table.

Worked example: calculate an audio size

A stereo recording uses a sample rate of 32,768 samples per second, a bit depth of 16 bits per sample, and a duration of 20 seconds.

size = (32,768 x 16 x 20 x 2) / (8 x 1024^2) MiB

size = 2.5 MiB

Omitting x 2 would calculate only one channel.

Faded example: find a missing duration

A stereo recording contains 6 MiB of audio data. Its sample rate is 32,768 samples per second and its bit depth is 16 bits per sample. Convert the known size to bits, then divide by the number of bits produced each second:

duration = (6 x 1024^2 x 8) / (32,768 x 16 x 2) seconds

duration = 48 seconds

Before accepting any storage expression, check five things: every supplied quantity appears once, time uses seconds, channels are included, bit/byte conversion points in the right direction, and the final unit is stated.