Welcome to Units of Information!
Hi there! Welcome to one of the most fundamental chapters in Computer Science. Before we dive into complex programming or AI, we need to understand the "language" computers speak. In this chapter, we are going to explore how computers measure information. Don't worry if you’re not a math whiz—we'll break everything down into simple steps with plenty of analogies!
1. The Smallest Building Blocks: Bits and Bytes
Everything you see on a computer—photos, games, even this text—is made of tiny switches that are either ON or OFF.
What is a Bit?
A bit (short for binary digit) is the fundamental unit of information. It is the smallest possible piece of data a computer can understand. Think of a bit like a single light switch: it can only be in one of two states: 0 (off) or 1 (on).
What is a Byte?
A single bit can't tell us much, so we group them together. A byte is a group of 8 bits.
Example: A byte might look like this: 10110010.
The Power of \(2^n\)
One of the most important rules to remember is that if you have n bits, you can represent \(2^n\) different values.
Don't let the formula scare you! It just means every time you add a bit, you double the number of combinations you can make.
Let's see it in action:
1 bit = \(2^1\) = 2 combinations (0, 1)
2 bits = \(2^2\) = 4 combinations (00, 01, 10, 11)
3 bits = \(2^3\) = 8 combinations (000, 001, 010, 011, 100, 101, 110, 111)
Quick Review:
• Bit: Smallest unit (0 or 1).
• Byte: 8 bits.
• Rule: \(n\) bits = \(2^n\) possible values.
Key Takeaway: Computers use bits as their basic alphabet, and we group them into bytes to store more complex information.
2. Measuring Large Amounts of Data
Just like we use grams and kilograms to measure weight, we use prefixes to measure large amounts of data. However, in Computer Science, there are two different ways to do this: Decimal Prefixes and Binary Prefixes.
Decimal Prefixes (Powers of 10)
These are the prefixes you probably use every day (like in "kilometers"). They are based on powers of 10 (multiples of 1,000).
• kilo (k): \(10^3\) (1,000)
• mega (M): \(10^6\) (1,000,000)
• giga (G): \(10^9\) (1,000,000,000)
• tera (T): \(10^{12}\) (1,000,000,000,000)
Binary Prefixes (Powers of 2)
Because computers work in binary, measuring in 1,000s isn't perfectly accurate for them. Computer scientists created binary prefixes based on powers of 2 (multiples of 1,024). These are the ones you need to know for your exam!
• kibi (Ki): \(2^{10}\) (1,024)
• mebi (Mi): \(2^{20}\) (1,048,576)
• gibi (Gi): \(2^{30}\) (1,073,741,824)
• tebi (Ti): \(2^{40}\) (1,099,511,627,776)
Memory Aid: Notice the "bi" in the middle of the names (Kibi, Mebi)? That stands for Binary! If you see the "bi," think Power of 2 (1,024).
Did you know?
For a long time, everyone just used the word "Kilobyte" to mean 1,024. This caused a lot of confusion because a "Kilo" in science always means exactly 1,000. To fix this, the industry introduced "Kibibyte" to be specific to the 1,024 version.
Key Takeaway: Use kilo/mega/giga for powers of 10 (\(10^3\), \(10^6\), etc.) and kibi/mebi/gibi for powers of 2 (\(2^{10}\), \(2^{20}\), etc.).
3. Converting Between Units
In your exams, you might be asked to show how many bytes are in a specific quantity. It's easier than it looks! You just need to know which "multiplier" to use.
Step-by-Step Examples:
Example 1: How many bytes are in 1 Kilobyte (kB)?
Step 1: Check the prefix. "Kilo" is decimal (\(10^3\)).
Step 2: Calculate. \(1 \times 10^3 = 1,000\).
Answer: 1,000 bytes.
Example 2: How many bytes are in 1 Kibibyte (KiB)?
Step 1: Check the prefix. "Kibi" is binary (\(2^{10}\)).
Step 2: Calculate. \(1 \times 2^{10} = 1,024\).
Answer: 1,024 bytes.
Example 3: Representing 5 Mebibytes (5 MiB) in bytes.
Simply write it as a power of 2: \(5 \times 2^{20}\) bytes.
Common Mistake to Avoid:
Don't mix up the symbol and the multiplier!
• kB (Lowercase 'k') = 1,000 bytes.
• KiB (Capital 'K') = 1,024 bytes.
Quick Review Box:
\(2^{10} = 1,024\) (Kibi)
\(2^{20} = 1,024 \times 1,024\) (Mebi)
\(2^{30} = 1,024 \times 1,024 \times 1,024\) (Gibi)
Key Takeaway: Always look for the "i" in the prefix (like MiB). If it's there, use the power of 2. If it's not (like MB), use the power of 10.
4. Summary Table for Revision
Use this table to quickly check the values for your exam preparation:
Decimal (Power of 10)
kilo (k) = \(10^3\)
mega (M) = \(10^6\)
giga (G) = \(10^9\)
tera (T) = \(10^{12}\)
Binary (Power of 2)
kibi (Ki) = \(2^{10}\)
mebi (Mi) = \(2^{20}\)
gibi (Gi) = \(2^{30}\)
tebi (Ti) = \(2^{40}\)
Final Encouragement: You've got this! Just remember that computers are simple at heart—everything is just a collection of bits, grouped into bytes, and measured in powers of 2. Practice writing out the powers of 2, and you'll be an expert in no time!