Why Do Computers Use Binary?
Imagine you’re building a machine that only understands on and off—like a really simple light switch. A computer is essentially a massive collection of these switches, called transistors, which can either be on (1) or off (0).
Since computers operate using electrical signals, having just two states—on (1) and off (0)—makes things much simpler and more reliable. This is why everything inside a computer is stored as binary (base-2) instead of decimal (base-10), which we humans use.
Everything from images to sound and text is stored in binary. Even a YouTube video is just a massive collection of 1s and 0s!
Since computers only understand 0s and 1s, we need a way to represent numbers using just those two symbols.
How Does Binary Work?
Think of decimal numbers:
The number 325 means:
3 hundreds, 2 tens, and 5 ones → (3 × 100) + (2 × 10) + (5 × 1).
Binary works the same way, but instead of 10s, it uses powers of 2:
The binary number 101 means:
(1 × 4) + (0 × 2) + (1 × 1) = 5 in decimal.
💡 Example: Convert 157 to Binary
1️⃣ Find the biggest power of 2 that fits into 157 → It’s 128.
2️⃣ Subtract 128 from 157 → 29 remains.
3️⃣ The next biggest power of 2 is 16 → Subtract 16 → 13 remains.
4️⃣ The next biggest power of 2 is 8 → Subtract 8 → 5 remains.
5️⃣ The next biggest power of 2 is 4 → Subtract 4 → 1 remains.
6️⃣ The next biggest power of 2 is 1 → Subtract 1 → 0 remains (we’re done!).
So, 157 in binary = 10011101
✔ = 1, ❌ = 0
So 157 = 10011101 in binary.
To convert binary back to decimal, just add up the place values where there’s a 1.
💡 Example: Convert 10011101 to decimal 1️⃣ Look at the positions of the 1s:
10011101
(128 + 16 + 8 + 4 + 1) = 157 ✅
So 10011101 = 157 in decimal.
How Many Numbers Can We Store in 8 Bits?
An 8-bit binary number has 8 places, where each place can be either 0 or 1.
This means we can create a total of 2⁸ = 256 different values!
💡 Lowest Value? → 00000000 (All bits off) → Decimal 0
💡 Highest Value? → 11111111 (All bits on) → Decimal 255
🧠 How Does This Work?
Binary uses place values that double every time:
Each 1 in a binary number adds that value to the total.
🔢 Example 1: The Number 0
All zeros mean 0 in decimal.
🔢 Example 2: The Number 255
All ones mean 255 in decimal:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
⚡️ Quick Recap
✅ Binary with 8 bits can store numbers from 0 to 255 (256 values in total).
✅ Each bit doubles in value from right to left.
✅ To find a decimal value, add up all the place values where there’s a 1.
✅ Binary is the language of computers—only 1s and 0s.
✅ Binary place values double each time (1, 2, 4, 8, 16…).
✅ To convert decimal to binary, subtract the biggest power of 2 first.
✅ To convert binary to decimal, add up the 1s' place values.
💡 Practice tip: Use the divide-by-2 method or a place value table to help with conversions.
Why Do We Need Floating Point Numbers?
Binary numbers are great for whole numbers, but what about decimals like 3.75 or 0.125?
Computers can’t store decimal points directly, so they use floating point representation, which works like scientific notation.
📏 The Two Parts of a Floating Point Number
A floating point number has two key parts:
1️⃣ Mantissa – The main number (stores the precision).
2️⃣ Exponent – Tells us where to move the decimal point.
Example:
In scientific notation, we write 0.58125 × 10⁴.
Mantissa = 0.58125
Exponent = 4
💡 In binary, the same concept applies, but with powers of 2 instead of 10.
🔢 How Floating Point Works in Binary
A floating point number in binary might look like:
👉 1.101 × 2³
1.101 (Mantissa) → The actual value.
2³ (Exponent) → Moves the decimal 3 places to the right.
So:
1.101 × 2³ = 1101.0 in binary = 13 in decimal.
📌 Key Takeaways
✅ Floating point allows computers to store decimal numbers.
✅ Uses a mantissa (value) and an exponent (scale).
Computers don’t understand letters or words—they only work with numbers (binary 0s and 1s).
So, how do we store text? By giving each character a unique number!
🔡 ASCII: The Standard for Text Storage
Every character (A, B, C, etc.) has a unique number assigned to it.
Example:
'A' = 65 in ASCII (01000001 in binary).
'B' = 66 (01000010), and so on.
But there’s a problem—ASCII only supports 128 characters, which isn’t enough for all languages.
Unicode (The Fix)
Unicode expands on ASCII, allowing for thousands of characters, including £, ñ, 你好, and even emojis!
Example: £ = 163, 😃 = U+1F603.
Think of ASCII as the basic alphabet and Unicode as the full multilingual dictionary.
ASCII characters fall into two categories:
✔ Printable Characters → Letters (A-Z, a-z), numbers (0-9), symbols (@, #, &).
✔ Control Characters → Non-visible instructions (Escape, Delete, Enter, Tab).
💡 Example: Pressing the Enter key sends the ASCII code 13 (Carriage Return) to the computer.
Every ASCII character takes 8 bits (1 byte) of storage in Extended ASCII.
🧮 How to Calculate Storage Space
Use the formula:
💡 Total bits needed = Number of characters × 8
🔢 Example: "No, I am your father!"
Number of characters: 21 (spaces and punctuation count too!)
Each character = 8 bits
Total storage = 21 × 8 = 168 bits
✅ ASCII stores text by assigning each character a unique number.
✅ 8-bit Extended ASCII stores up to 256 characters.
✅ Control characters like Enter, Delete, and Tab don’t print but send instructions.
✅ Unicode was introduced to store more languages and symbols.
✅ To calculate storage, multiply characters by 8 bits per character.
Computers store images in different ways, depending on what kind of image it is.
The two main types are:
Bitmap Graphics (Pixel-based)
Vector Graphics (Formula-based)
Each type has its strengths and weaknesses!
What is a Bitmap?
A bitmap image is made up of a grid of tiny squares called pixels (short for "picture elements").
Each pixel has a specific color, and when combined, they form an image.
Key Features of Bitmaps
✔ Resolution-dependent – If you zoom in or resize, pixels become visible (pixelation).
✔ Larger file sizes – High-resolution images require more pixels, meaning more storage.
✔ Good for complex images – Used for photographs and detailed artwork.
💡 The more pixels an image has, the higher the resolution and detail.
Bitmap Storage Calculation
💡 To calculate file size of a bitmap:
🖼 File Size (bits) = Width × Height × Colour Depth
✔ Example: A 4×4 image, 8-bit colour depth
🔹 4 × 4 = 16 pixels
🔹 8 bits per pixel → 16 × 8 = 128 bits total
What is a Vector Graphic?
Unlike bitmaps, vector graphics don’t use pixels! Instead, they are made up of mathematical formulas that define shapes, lines, and curves.
Key Features of Vectors
✔ Resolution-independent – Can be scaled infinitely without losing quality.
✔ Smaller file sizes – Uses less storage since it only stores mathematical formulas, not millions of pixels.
✔ Best for simple graphics – Used in logos, icons, and illustrations.
Vector Components
Each shape in a vector graphic has attributes, including:
✔ Fill colour (e.g., blue rectangle)
✔ Line colour (e.g., black outline)
✔ X and Y coordinates (position of the object)
💡 Because vectors use formulas instead of pixels, they stay sharp no matter the size!
Example: Scaling Differences
📷 Bitmap (pixel-based) vs. Vector (formula-based)
✔ Vectors stay smooth, while bitmaps get pixelated!
✅ Bitmap images = made of pixels, detailed but can become pixelated.
✅ Vector images = made of math formulas, can be resized without losing quality.
✅ Bitmaps are best for photos, vectors are best for logos, icons, and illustrations.
✅ File size: Bitmaps are bigger, vectors are smaller.