Course 1.3Lesson 1 of 3
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.
Try the code and the simulations beside the lesson.
You have met the bit, a single 0 or 1. It is the smallest unit of data. Bits are grouped into 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 , a power of two, which suits binary.
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.
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 KiB.
Going up: divide. How many MiB is 5120 KiB? One step up, so MiB.
Two steps. How many bytes is 2 MiB? Two steps down: bytes. To get bits, multiply by 8 as well: bits.
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.
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.