← IGCSE Computer Science Paper 1

Checking whether a file fits in the available storage

A file fits if its size is less than or equal to the free space. First convert both to the same unit, such as bytes or MiB, then compare the two numbers.

Understanding Checking whether a file fits in the available storage in IGCSE Computer Science Paper 1

What it does: 1 GiB is 1024 MiB, so 2 GiB is 2048 MiB. Both are now in MiB, and 1500 is less than 2048, so the file fits. Capacity and file size are already in MiB, so dividing 64 by 4 gives 16 images that fit. The numbers only mean something when the units match. 2 GiB = 2048 MiB, so compare 600 MiB with 2048 MiB. 1 GiB = 1024 MiB. Divide 1024 by 4 to get 256 images. 1 GiB = 1024 MiB. 1024 / 250 = 4.096, so only 4 whole files fit. A part of a file does not count.

Common mistakes: To convert GiB to MiB you multiply by 1024, not 1000. It should be driveMiB ← driveGiB * 1024, so both sizes are in MiB before comparing. A file fits when its size is less than or equal to the free space. The test should be fileMiB <= freeMiB, not >.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 69–84) and word search (Modules 59–84).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A 600 MiB video is to be saved on a 2 GiB drive. What must you do before comparing the two sizes?
Compare 600 and 2 directlyConvert both to the same unit
Matches
5 MiB file on 4096 KiB: 5 <= 4096, so it fits
↓
The numbers are in different units: 5 is in MiB but 4096 is in KiB. Comparing them directly is wrong.
Applying
Meanings
Term
file size <= capacity
Meaning
A file fits if its size is less than or equal to the free space. First convert both to the same unit, such as bytes or MiB, then compare the two numbers.
Practice
fileSizeMiB ← 1500
Testing
Gaps
IF fileSize freeSpace THEN
Check Answer
Spots
2driveGiB ← 2
3driveMiB ← driveGiB * 1000

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cheetah' badge — Savannah Sprinter, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A 600 MiB video is to be saved on a 2 GiB drive. What must you do before comparing the two sizes?
A. Convert both to the same unit ✓
B. Compare 600 and 2 directly
The numbers only mean something when the units match. 2 GiB = 2048 MiB, so compare 600 MiB with 2048 MiB.
2. Which condition shows that a file fits in the free space?
A. file size > free space
B. file size <= free space ✓
A file fits when its size is less than or equal to the free space, once both are in the same unit.
3. A 3 GiB file and a drive with 2048 MiB free. Does the file fit?
A. No, 3 GiB = 3072 MiB, which is more than 2048 MiB ✓
B. Yes, because 3 is smaller than 2048
Never compare 3 with 2048 directly. Convert 3 GiB to 3072 MiB first, and that is bigger than 2048 MiB.
4. A sound file is 512 KiB and the free space is 1 MiB. Does the file fit?
A. No, because 1 is smaller than 512
B. Yes, 1 MiB = 1024 KiB and 512 KiB is less than 1024 KiB ✓
Convert 1 MiB to 1024 KiB. Then 512 <= 1024, so the file fits.
5. A 2 GiB file is saved onto a drive with exactly 2048 MiB free. Does it fit?
A. Yes, the sizes are equal so it just fits ✓
B. No, the file must be strictly smaller
2 GiB = 2048 MiB. The rule is size <= capacity, so a file the same size as the free space still fits.

Match the Pairs

file_bytes <= free_bytes → The file fits because both sizes are in bytes and the file is not bigger than the free space
files = capacity // file_size → Works out how many whole files fit in the storage, after both sizes are in the same unit
Convert a 2 GiB drive into MiB before comparing it with a 1500 MiB sound file → 2 * 1024 = 2048 MiB, so 1500 <= 2048
Find how many 4 MiB images fit on a 64 MiB card → 64 / 4 = 16 images
5 MiB file on 4096 KiB: 5 <= 4096, so it fits → The numbers are in different units: 5 is in MiB but 4096 is in KiB. Comparing them directly is wrong.
File 3 GiB, drive 2048 MiB: 3 <= 2048, so it fits → The file size is in GiB and the drive is in MiB, so comparing 3 with 2048 is not a fair check.

Key Term

file size <= capacity
A file fits if its size is less than or equal to the free space. First convert both to the same unit, such as bytes or MiB, then compare the two numbers.

Fill in the Blanks

1. IF fileSize <= freeSpace THEN
Hint: Type the comparison operator for less than or equal to, so a file that exactly fills the space still fits.
2. freeBytes ← freeMiB * 1024 * 1024
Hint: Type the number you multiply by to change KiB into bytes. MiB to bytes takes two steps of the same size.
3. freeMiB ← 100 fileMiB ← 8 numFiles ← freeMiB DIV fileMiB
Hint: Type the operator that gives whole-number division, because only complete files can be stored.
4. IF fileMiB <= freeMiB THEN
Hint: Type the keyword that follows the condition in an IF statement.
5. imageMiB ← 350 driveMiB ← 2048 IF imageMiB <= driveMiB THEN
Hint: Type the variable that holds the drive size in the same unit as the image size, so the two numbers can be compared.

Spot the Error

Question 1
A fileMiB ← 300
B driveGiB ← 2
C driveMiB ← driveGiB * 1000
D IF fileMiB <= driveMiB THEN
E OUTPUT "Fits"
F ENDIF
Line C — To convert GiB to MiB you multiply by 1024, not 1000. It should be driveMiB ← driveGiB * 1024, so both sizes are in MiB before comparing.
Question 2
A fileMiB ← 600
B freeMiB ← 650
C IF fileMiB > freeMiB THEN
D OUTPUT "Fits"
E ENDIF
Line C — A file fits when its size is less than or equal to the free space. The test should be fileMiB <= freeMiB, not >.
Question 3
A capGiB ← 1
B capMiB ← capGiB / 1024
C fileMiB ← 4
D count ← capMiB DIV fileMiB
E OUTPUT count
Line B — Going from GiB to the smaller unit MiB means multiplying by 1024, not dividing. It should be capMiB ← capGiB * 1024.
Question 4
A fileBytes ← 2 * 1024
B freeBytes ← 3000000
C IF fileBytes <= freeBytes THEN
D OUTPUT "Fits"
E ENDIF
Line A — 2 MiB in bytes needs two multiplications by 1024 (MiB to KiB to bytes). It should be fileBytes ← 2 * 1024 * 1024.
Question 5
A imageBytes ← 6291456
B imageKiB ← imageBytes * 1024
C driveKiB ← 5000
D fits ← imageKiB <= driveKiB
E OUTPUT fits
Line B — Converting bytes to the larger unit KiB means dividing by 1024, not multiplying. It should be imageKiB ← imageBytes / 1024.

Student with a class code? Join your class →