HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Storage Units and Compression
  1. 1Units of data storage
  2. 2Calculating file sizes
  3. 3Compression: lossy, lossless and run-length encoding
  1. Computer Science
  2. /Storage Units and Compression
  3. /Units of data storage

Course 1.3·Lesson 1 of 3

Units of data storage

Data storage is measured in bits and bytes, and then in larger units that go up in steps of 1024. You learn the bit, the nibble and the byte, the units from the kibibyte to the exbibyte, and how to change a size from one unit to another.

about 20 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Storage Units and Compression
  1. 1Units of data storage
  2. 2Calculating file sizes
  3. 3Compression: lossy, lossless and run-length encoding

Try the code and the simulations beside the lesson.

Bits, nibbles and bytes

You have met the bit, a single 0 or 1. It is the smallest unit of data. Bits are grouped into larger units.

  • A nibble is 4 bits. One hexadecimal digit is one nibble.
  • A byte is 8 bits, which is 2 nibbles. One ASCII character usually takes one byte.

The larger units

A file quickly needs thousands or millions of bytes, so we use larger units. In this syllabus each unit is 1024 times the one before it. Why 1024? Because 1024=2101024 = 2^{10}1024=210, a power of two, which suits binary.

A ladder of storage units from the bottom up: bit, nibble, byte, KiB, MiB, GiB, TiB, PiB, EiB. Beside the steps: 4 bits make a nibble, 8 bits make a byte, and every step above the byte is 1024. Arrows on the side say multiply by 1024 going down and divide by 1024 going up.
  • 1 kibibyte (KiB) =1024= 1024=1024 bytes.
  • 1 mebibyte (MiB) =1024= 1024=1024 KiB.
  • 1 gibibyte (GiB) =1024= 1024=1024 MiB.
  • 1 tebibyte (TiB) =1024= 1024=1024 GiB.
  • 1 pebibyte (PiB) =1024= 1024=1024 TiB.
  • 1 exbibyte (EiB) =1024= 1024=1024 PiB.

The names end in "bi" for binary. You may see kilobytes (kB) of 1000 bytes on some devices. In this syllabus, calculations must use 1024 and not 1000.

Changing units

Think of a ladder. Each step up divides by 1024, and each step down multiplies by 1024. The only different steps are at the bottom: 8 bits make a byte, and 4 bits make a nibble.

Going down: multiply. How many KiB are in 3 MiB? One step down, so 3×1024=30723 \times 1024 = 30723×1024=3072 KiB.

Going up: divide. How many MiB is 5120 KiB? One step up, so 5120÷1024=55120 \div 1024 = 55120÷1024=5 MiB.

Two steps. How many bytes is 2 MiB? Two steps down: 2×1024×1024=20971522 \times 1024 \times 1024 = 20971522×1024×1024=2097152 bytes. To get bits, multiply by 8 as well: 167772161677721616777216 bits.

Practise with new numbers

Try it in Python

The program takes a number of bytes and keeps dividing by 1024 until the number is small. Then it prints the size in the largest unit that fits.

Read it first. Then run it. Which unit does it choose?

1. Change size = 3221225472 to size = 1536. Predict the answer before you run it.

2. Give it a size above one tebibyte. Does the list of units need to grow?

Common mistakes

  • Using 1000. Every step is 1024 in this syllabus.
  • Multiplying when you should divide. A bigger unit gives a smaller number.
  • Forgetting the 8. Bits to bytes is a step of 8, not 1024.
  • Mixing up a nibble and a byte. A nibble is half a byte.

Remember these

  • 4 bits === 1 nibble. 8 bits === 1 byte.
  • KiB, MiB, GiB, TiB, PiB, EiB: each is 1024 of the one before.
  • Down the ladder: multiply. Up the ladder: divide.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. How many bits are in 5 nibbles?
  1. How many MiB are in 7 GiB?
  1. A file is 4096 KiB. How many MiB is that?
  1. Put these in order from smallest to largest: TiB, KiB, PiB, MiB.
  1. How many bytes are in 1 GiB? Give the answer as a power of 2.

Enroll free in Storage Units and Compression

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A camera has a memory card of 32 GiB. A student wants to know the size in smaller units…Easy · High School (9–10) · by StemPy Lab
A school keeps backup copies on a disk of 2 TiB…Medium · High School (9–10) · by StemPy Lab
A data centre reports sizes in odd units, and an engineer tidies them up…Hard · High School (9–10) · by StemPy Lab
Next: lesson 2Calculating file sizes
← Storage Units and Compression
← PreviousCalculating file sizes →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.