Binary & Data Representation
How computers represent all data, from text to images, using binary and hexadecimal systems.
**Introduction & Core Concept**
*Assalam-o-Alaikum*, students. I am Dr. Amir Hussain, and for the next twenty years, I've had the privilege of guiding students like you through the fascinating world of Computer Science. Today, we embark on a journey to the very heart of the digital universe.
Imagine this: you're sitting in a café on M. M. Alam Road in Lahore, and you send a WhatsApp message to your cousin in Karachi. The message says, "Cricket match ka score kya hai? 🤔". Within seconds, your cousin receives the exact same Urdu text and the thinking-face emoji.
Have you ever stopped to wonder what happened in those seconds? How did your phone transform your thoughts, typed in the Urdu script, into something that could travel across Pakistan through fibre optic cables and radio waves? The answer is the single most fundamental concept in all of computing: binary.
At its core, every computer, from the supercomputer at a research institute to the smartphone in your pocket, is an incredibly complex collection of billions of microscopic electronic switches. Each switch can only be in one of two states: ON or OFF. That’s it. There is no in-between.
To represent these two states, we use a number system with only two digits: 1 (for ON) and 0 (for OFF). This is the binary system, or base-2.
The "big picture" mental model you must grasp is Abstraction. We take this ridiculously simple system of ONs and OFFs and build layers upon layers of meaning on top of it.
- We group these 1s and 0s to represent numbers.
- We assign numbers to represent letters and symbols (like 'A', 'ب', or '?').
- We arrange these letters into words and sentences.
- We group bits in another way to represent the colour of a single dot (a pixel).
- We arrange millions of these coloured dots to form a picture of the Badshahi Mosque.
Everything digital—your exam results, your favourite Coke Studio song, the very website you are reading this on—is, at its deepest level, just an unimaginably long sequence of 1s and 0s. This lesson will teach you the language of the machine, enabling you to understand not just *what* a computer does, but *how* it thinks.
**Theoretical Foundation**
To truly understand how computers represent data, we must first master the number systems they use. We will build from the familiar to the new.
1. The Denary System (Base-10): Our Everyday Numbers
The number system we've used our entire lives is called denary or base-10. Why "base-10"? Because it uses ten unique digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
The core principle is place value. Each position in a number has a value that is a power of 10. Consider the number 582. It isn't 'five' and 'eight' and 'two'. It is:
- (5 × 100) + (8 × 10) + (2 × 1)
- Which is the same as: `(5 * 10²) + (8 * 10¹) + (2 * 10⁰)`
Notice that any number to the power of 0 is 1. This is a fundamental mathematical rule. The place values, reading from right to left, are 1, 10, 100, 1000, and so on.
2. The Binary System (Base-2): The Computer's Language
Computers cannot use base-10 because their electronic switches don't have ten different states. They only have two: ON (1) and OFF (0). So, they use the binary or base-2 system.
Binary works on the exact same principle of place value, but the base is 2 instead of 10. The place values, again reading from right to left, are powers of 2:
`... 2⁷, 2⁶, 2⁵, 2⁴, 2³, 2², 2¹, 2⁰`
Which equates to:
`... 128, 64, 32, 16, 8, 4, 2, 1`
The fundamental unit is a bit (short for binary digit), which is a single 0 or 1. To represent anything meaningful, we group bits together. The most common grouping is a byte, which is a group of 8 bits.
Conversion: Binary to Denary
This is the easier conversion. You simply multiply each bit by its place value and sum the results.
Let's convert the binary number `10110101` to denary.
First, place it under the place value headings:
| 128 (2⁷) | 64 (2⁶) | 32 (2⁵) | 16 (2⁴) | 8 (2³) | 4 (2²) | 2 (2¹) | 1 (2⁰) |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
Now, add the place values where the bit is a '1':
`128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181`
So, the binary number `10110101₂` is equal to the denary number `181₁₀`. The small subscript number indicates the base.
Conversion: Denary to Binary
This can seem tricky, but there is a reliable method called "repeated division by 2". Here’s the logic behind it: When you divide a denary number by 2, the remainder will either be 0 (if the number is even) or 1 (if the number is odd). This remainder gives you the value for the least significant bit (the 1s place, or `2⁰`). The result of the division then represents the rest of the number, which you can divide by 2 again to find the next bit, and so on.
Let's convert the denary number `155` to binary.
- `155 ÷ 2 = 77` with a remainder of 1 (This is our `2⁰` bit)
- `77 ÷ 2 = 38` with a remainder of 1 (This is our `2¹` bit)
- `38 ÷ 2 = 19` with a remainder of 0 (This is our `2²` bit)
- `19 ÷ 2 = 9` with a remainder of 1 (This is our `2³` bit)
- `9 ÷ 2 = 4` with a remainder of 1 (This is our `2⁴` bit)
- `4 ÷ 2 = 2` with a remainder of 0 (This is our `2⁵` bit)
- `2 ÷ 2 = 1` with a remainder of 0 (This is our `2⁶` bit)
- `1 ÷ 2 = 0` with a remainder of 1 (This is our `2⁷` bit)
The process stops when the result of the division is 0. Now, and this is the crucial part, you read the remainders from the bottom up.
So, `155₁₀` = `10011011₂`.
3. The Hexadecimal System (Base-16): Human-Friendly Shorthand
Looking at a long string of binary like `1011010110011110` is difficult for humans. It's easy to make a mistake. To solve this, computer scientists use the hexadecimal (or 'hex') system as a more compact and readable way to represent binary data.
Hexadecimal is base-16. This means it needs 16 unique digits. We use the familiar 0-9, but what about the other six? We use the letters A through F.
- `0-9` represent the values zero to nine.
- `A` represents the value ten.
- `B` represents the value eleven.
- `C` represents the value twelve.
- `D` represents the value thirteen.
- `E` represents the value fourteen.
- `F` represents the value fifteen.
The magic of hexadecimal lies in its relationship with binary. The largest number you can represent with 4 bits (a nibble) is `1111₂`, which is `8 + 4 + 2 + 1 = 15`. This is the exact range of a single hexadecimal digit (0 to 15, or 0 to F)!
This means one hexadecimal digit is a perfect shorthand for four binary digits (one nibble).
Conversion: Hexadecimal to Binary
This is the most straightforward conversion. Simply convert each hex digit into its 4-bit binary equivalent.
Let's convert `4B₉F₁₆` to binary.
- `4` = `0100`
- `B` (which is 11) = `1011` (`8+2+1`)
- `9` = `1001`
- `F` (which is 15) = `1111` (`8+4+2+1`)
Just string them together: `0100 1011 1001 1111₂`.
Conversion: Binary to Hexadecimal
This is the reverse process. Take your binary string, and starting from the right, split it into groups of 4 (nibbles). If the last group on the left doesn't have 4 bits, add leading zeros. Then, convert each nibble to its hex equivalent.
Let's convert `11010110101100₂`.
- Split into nibbles from the right: `11` `0101` `1010` `1100`
- The leftmost group only has two bits. Add leading zeros: `0011` `0101` `1010` `1100`
- Convert each nibble:
- `0011` = `3`
- `0101` = `5`
- `1010` = `10`, which is `A` in hex.
- `1100` = `12`, which is `C` in hex.
So, `11010110101100₂` = `35AC₁₆`.
Conversion: Hexadecimal to Denary
This works just like binary to denary, but the place values are powers of 16.
Place values (right to left): `... 16³, 16², 16¹, 16⁰` which is `... 4096, 256, 16, 1`.
Let's convert `2A5₁₆` to denary.
- `2A5₁₆ = (2 * 16²) + (A * 16¹) + (5 * 16⁰)`
- Remember, `A` is 10.
- `= (2 * 256) + (10 * 16) + (5 * 1)`
- `= 512 + 160 + 5`
- `= 677₁₀`
4. Representing Data
Now that we understand the number systems, let's see how they are used.
a) Text: Character Sets
How does `01000001` become the letter 'A'? Because a standard says so. A character set is a list of characters and the unique binary code assigned to each one.
- ASCII (American Standard Code for Information Interchange): This was the early standard. Originally 7-bit, it could represent `2⁷ = 128` different characters (English letters, numbers, punctuation). Extended ASCII uses 8 bits (a full byte), allowing for `2⁸ = 256` characters, which includes some European accented characters. However, this is hopelessly inadequate for the world's languages.
- Unicode: This is the modern standard. It uses a much larger range, up to 32 bits for a character, allowing it to represent over a million unique characters. This is why you can type in English, Urdu, Arabic, Chinese, and use emojis on the same page. Unicode is the reason the digital world is a global village. The first 128 characters of Unicode are identical to ASCII for backward compatibility.
b) Images: Bitmaps
A digital image is not a single entity. It's a grid of tiny dots called pixels (picture elements). A bitmap image stores information about every single pixel.
- Resolution: The size of this grid, measured as `width x height` (e.g., 1920 x 1080 pixels).
- Colour Depth: The number of bits used to store the colour of a single pixel.
- A 1-bit colour depth can only store two colours (`2¹ = 2`), typically black and white.
- An 8-bit colour depth can store `2⁸ = 256` different colours.
- A 24-bit "True Colour" image uses 8 bits for Red, 8 bits for Green, and 8 bits for Blue (RGB). This allows for `2²⁴` (over 16 million) different colours, which is more than the human eye can distinguish.
c) Sound: Sampling
Sound in the real world is an analogue wave—it's continuous and smooth. A computer cannot store a continuous wave. It must convert it into a series of discrete numbers. This process is called sampling.
- An Analogue-to-Digital Converter (ADC) measures the amplitude (height) of the sound wave at regular, tiny intervals.
- Sample Rate: How many times per second the wave's amplitude is measured. This is measured in Hertz (Hz). A typical CD-quality sample rate is 44,100 Hz (44.1 kHz).
- Bit Depth (or Sample Resolution): The number of bits used to store the value of each individual measurement. A higher bit depth allows for a more accurate representation of the amplitude. CD quality is 16-bit.
Essentially, digital audio is a "connect-the-dots" approximation of a real sound wave, where the dots are taken very, very frequently.
**Key Definitions & Formulae**
- Bit: The smallest unit of data in a computer, represented as a 0 or 1.
- Byte: A group of 8 bits. The standard unit for representing a single character.
- Nibble: A group of 4 bits.
- Kilobyte (KB): Traditionally 1024 bytes (`2¹⁰` bytes), but often used by storage manufacturers to mean 1000 bytes. In exams, assume 1 KB = 1024 Bytes unless told otherwise.
- Megabyte (MB): 1024 KB.
- Gigabyte (GB): 1024 MB.
- Terabyte (TB): 1024 GB.
- Hexadecimal: A base-16 number system using digits 0-9 and A-F. Used as a human-friendly shorthand for binary.
- ASCII: An early 7 or 8-bit character set primarily for the English language.
- Unicode: A modern character set standard that can represent characters from almost all of the world's writing systems.
- Pixel: A single point of colour in a digital image.
- Resolution: The dimensions of a bitmap image, given as `Width × Height` in pixels.
- Colour Depth: The number of bits used to represent the colour of a single pixel.
Key Formulae:
- Number of possible values: For `n` bits, the number of unique patterns (and thus values/colours/characters) you can represent is:
`Number of Values = 2ⁿ`
- Bitmap Image File Size (uncompressed):
`File Size (in bits) = Resolution Width (pixels) × Resolution Height (pixels) × Colour Depth (bits per pixel)`
To get the size in bytes, divide by 8. To get it in KB, divide the bytes by 1024.
- Sound File Size (uncompressed):
`File Size (in bits) = Sample Rate (Hz) × Bit Depth × Duration (seconds) × Number of Channels`
*(Number of Channels is 1 for mono, 2 for stereo)*
**Worked Examples**
Example 1: WAPDA Electricity Bill Calculation
Fatima in Gulberg, Lahore, receives her monthly WAPDA bill. The meter reading for the month is `350` units (kWh). The smart meter needs to store this value in an 8-bit binary register before transmitting it. Convert `350₁₀` to binary. Will it fit in an 8-bit register?
Working:
An 8-bit register can store a maximum value of `11111111₂`.
`128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255`.
Instantly, we can see that `350` is greater than `255`, so it will not fit in a single 8-bit register. This is a crucial first check. A 16-bit register would be needed.
Let's perform the conversion anyway to demonstrate the process. We use repeated division by 2.
- `350 ÷ 2 = 175` remainder `0`
- `175 ÷ 2 = 87` remainder `1`
- `87 ÷ 2 = 43` remainder `1`
- `43 ÷ 2 = 21` remainder `1`
- `21 ÷ 2 = 10` remainder `1`
- `10 ÷ 2 = 5` remainder `0`
- `5 ÷ 2 = 2` remainder `1`
- `2 ÷ 2 = 1` remainder `0`
- `1 ÷ 2 = 0` remainder `1`
Reading the remainders from the bottom up, we get `101011110₂`.
This is a 9-bit number, confirming it cannot be stored in an 8-bit register.
Answer: The denary value `350` is `101011110` in binary. It will not fit in an 8-bit register as it requires 9 bits. The maximum value an 8-bit register can hold is `255`.
Example 2: PTCL Engineer and MAC Addresses
An engineer from PTCL is troubleshooting a network issue in Saddar, Karachi. They are looking at the MAC (Media Access Control) address of a router, which is a unique hardware identifier. MAC addresses are written in hexadecimal. A part of the address is `D8-4C`. The engineer needs to understand the binary representation of this segment.
Task: Convert the hexadecimal value `D84C₁₆` to binary and to denary.
Working (Hex to Binary):
We convert each hex digit into its 4-bit binary equivalent.
- `D` = `13` in denary. In binary, `13 = 8 + 4 + 1`, which is `1101`.
- `8` = `8` in denary. In binary, this is `1000`.
- `4` = `4` in denary. In binary, this is `0100`.
- `C` = `12` in denary. In binary, `12 = 8 + 4`, which is `1100`.
Combine these nibbles: `1101 1000 0100 1100₂`.
Working (Hex to Denary):
We use the place values for base-16: `16³, 16², 16¹, 16⁰` (4096, 256, 16, 1).
`D84C₁₆ = (D * 16³) + (8 * 16²) + (4 * 16¹) + (C * 16⁰)`
Substitute the denary values for D (13) and C (12):
`= (13 * 4096) + (8 * 256) + (4 * 16) + (12 * 1)`
`= 53248 + 2048 + 64 + 12`
`= 55372₁₀`
Answer: The hexadecimal value `D84C₁₆` is `1101100001001100₂` in binary and `55372₁₀` in denary.
Example 3: Photographing the Indus River Dolphin
A wildlife photographer takes a high-resolution, uncompressed digital photo of a rare Indus River Dolphin. The image has a resolution of 4000 x 3000 pixels and uses a 24-bit colour depth. Calculate the file size of this image in megabytes (MB).
Working:
- Use the file size formula:
`File Size (bits) = Width × Height × Colour Depth`
`File Size (bits) = 4000 × 3000 × 24`
`File Size (bits) = 12,000,000 × 24 = 288,000,000 bits`
- Convert bits to bytes: There are 8 bits in a byte.
`File Size (bytes) = 288,000,000 / 8 = 36,000,000 bytes`
- Convert bytes to kilobytes (KB): There are 1024 bytes in a KB.
`File Size (KB) = 36,000,000 / 1024 = 35156.25 KB`
- Convert kilobytes to megabytes (MB): There are 1024 KB in an MB.
`File Size (MB) = 35156.25 / 1024 ≈ 34.33 MB`
Answer: The file size of the photograph is approximately **34.33 MB**. (Showing all steps of the conversion is critical for marks).
**Visual Mental Models**
- The Odometer Model for Place Value:
Imagine the odometer in an old car. In a denary system, when a wheel goes from 9, it clicks back to 0 and bumps the wheel to its left up by one.
`008 -> 009 -> 010`
A binary odometer works the same way, but it only has 0 and 1. It "clicks over" much faster.
`001` (1) -> `010` (2) -> `011` (3) -> `100` (4)
This helps you visualise the "carrying over" process in binary addition and understand the rapidly increasing place values.
- The Light Switch Panel (for a Byte):
Picture a panel with 8 light switches in a row. Each switch can be either `UP` (ON = 1) or `DOWN` (OFF = 0).
`[DOWN] [UP] [UP] [DOWN] [UP] [DOWN] [UP] [UP]`
This physically represents the binary byte `01101011`. This is a powerful, tangible way to think about how a byte holds a pattern. To find its denary value, you'd just add the values of the "ON" switches (e.g., 64 + 32 + 8 + 2 + 1).
- The Mosaic Tile Model (for Bitmap Images):
Think of the beautiful mosaic tile work (kashi-kari) on the Wazir Khan Mosque in Lahore. From a distance, you see a complete, stunning picture. But if you get very close, you see it's made of thousands of individual, single-coloured tiles.
A bitmap image is exactly the same. Each 'tile' is a pixel. The 'colour' of the tile is stored as a binary number (e.g., `11111111 00000000 00000000` for pure red in 24-bit colour). The resolution is the number of tiles wide by the number of tiles high.
(Pixel) (Pixel) (Pixel) ...
[R,G,B] [R,G,B] [R,G,B] ...
[R,G,B] [R,G,B] [R,G,B] ...
... ... ...
- The Connect-the-Dots Wave (for Digital Sound):
Imagine a smooth, curving sound wave drawn on a graph. You can't store the infinite points on that curve. So, you place dots on the curve at equal intervals (the sample rate). Then you erase the original curve, leaving only the dots. The computer stores the height (amplitude) of each dot as a binary number. When you play the sound back, the computer connects the dots as best it can to recreate the wave. More dots (higher sample rate) and more precise vertical positions for the dots (higher bit depth) result in a sound that is closer to the original.
**Common Mistakes & Misconceptions**
- Place Value Direction Error: Students often calculate binary place values from left-to-right instead of right-to-left. They might think the first digit in `1010` is worth `1` instead of `8`.
* Why it's wrong: All positional number systems, including denary, have their lowest place value on the far right (`10⁰`, `2⁰`).
* Correct thinking: Always write the place values `128, 64, ..., 4, 2, 1` above the binary number, starting from the rightmost digit.
- Denary-to-Binary Remainder Order: When using the division method, students write down the remainders as they calculate them, from top to bottom.
* Why it's wrong: The first remainder you calculate is for the `2⁰` place (the least significant bit). The last remainder is for the highest place (the most significant bit).
* Correct thinking: Always read the list of remainders from the bottom up.
- Hexadecimal Digit Confusion: Thinking `C` is the letter 'C' or that `10₁₆` is the number ten.
* Why it's wrong: In hex, A-F are symbols representing the numbers 10-15. The value `10₁₆` is actually `(1 * 16¹) + (0 * 16⁰)`, which is `16` in denary.
* Correct thinking: Memorise that `A=10, B=11, C=12, D=13, E=14, F=15`. When you see a hex digit, immediately think of its denary equivalent.
- Confusing the Number 5 with the Character '5': A very common conceptual error is to think the binary for both is the same.
* Why it's wrong: The number 5 is represented in pure binary as `101₂`. The character '5' is represented by its ASCII/Unicode code point. The ASCII code for '5' is denary `53`, which is `00110101₂`.
* Correct thinking: A computer makes a clear distinction between a numerical value used for calculation and a character symbol used for display. They have completely different binary representations.
- The KB vs KiB Mix-up (1000 vs 1024): Students often use 1000 for conversions in all contexts.
* Why it's wrong: In computing contexts related to memory (RAM) and file sizes based on powers of 2, the "kilo" prefix means 1024 (`2¹⁰`). Hard drive manufacturers often use 1000 for marketing, which is why a 1 TB drive shows up as about 931 GB in your OS.
* Correct thinking: For your Cambridge exam, unless the question explicitly states otherwise, always use the binary prefixes: 1 KB = 1024 Bytes, 1 MB = 1024 KB, 1 GB = 1024 MB.
- Forgetting Units in File Size Calculations: Providing the answer to a file size question as just a number, e.g., "34.33".
* Why it's wrong: 34.33 what? Bits? Bytes? MB? GB? The unit is essential for the answer to have any meaning.
* Correct thinking: Always conclude your calculation with the correct units (e.g., MB). Double-check if the question asked for the answer in a specific unit.
**Exam Technique & Mark Scheme Tips**
Cambridge examiners are precise. You must be too.
- Understand Command Words:
* State: Give a concise answer. No explanation needed. "State the hexadecimal equivalent of `1110`." Answer: "E".
* Describe: Provide the key features of something. "Describe how a bitmap image is stored." Answer: "It is stored as a grid of pixels. The colour of each individual pixel is stored as a binary number."
* Explain: Give reasons *how* or *why* something works. This requires more depth. "Explain why Unicode is used instead of ASCII." Answer: "ASCII uses 8 bits and can only represent 256 characters, which is insufficient for global languages. Unicode uses a larger bit-space, allowing it to represent characters from all major languages, like Urdu, as well as symbols and emojis, making it a universal standard."
* Calculate: You must show your working. The final answer is often worth only one mark; the intermediate steps are where you earn the rest.
- Show Your Working Methodically: For a file size calculation, write out the formula first. Then substitute the values. Then show the result in bits, then bytes, then KB/MB. This way, even if you make a small calculator error at the end, you will get most of the marks for demonstrating the correct method.
* `(4000 * 3000 * 24) / 8 / 1024 / 1024` is a clear line of working that will earn marks.
- Hexadecimal is a Frequent Flyer: Examiners love hex-to-binary and binary-to-hex questions. Why? Because they test your understanding of nibbles and base conversions in one go. Be very comfortable with splitting binary into 4-bit groups and converting each to its hex digit.
- Master the `2ⁿ` Formula: This is your secret weapon. Any question that asks "How many unique..." (colours, characters, items, etc.) can be represented by `n` bits is answered with `2ⁿ`. A 5-bit system can represent `2⁵ = 32` unique things.
- Watch for Traps:
* A question might give you a file size in megabits (Mb) instead of megabytes (MB). Remember the lowercase 'b' means bits, uppercase 'B' means bytes.
* A question might ask for the file size in kilobytes (KB) but give you dimensions that result in a large MB value. Don't forget the final conversion step.
* Pay attention to whether a sound file is mono (1 channel) or stereo (2 channels), as this will double the file size.
**Memory Tricks & Mnemonics**
- Binary Place Values (A Cricket Mnemonic):
Think of a cricket over. It has 6 balls. An 8-bit byte is like a super-over. Remember the place values with this:
"128 Runs, 64 Not Out, 32 Fours, 16 Sixes, 8 Wides, 4 Byes, 2 No-balls, 1 Wicket."
It's a bit silly, but associating the numbers with cricket terms can make them stick.
- Hexadecimal A-F Values (10-15):
"Ali's Brother Can't Drive Expensive Ferraris."
- Ali (10 letters in "Ali's Broth") - Nope, that's too complex. Let's simplify.
- Just count on your fingers from 10. `A` is 10, `B` is 11, `C` is 12, `D` is 13, `E` is 14, `F` is 15.
- Or, for a mnemonic: `After Being Caught, Don't Ever Forget.` (A=10, B=11, C=12, D=13, E=14, F=15).
- Denary to Binary Method:
Divide Down, Read Remainders Up. (DDRU).
When converting Denary, you Divide. Then you Read the Remainders Upwards.
**Pakistan & Everyday Connections**
- Typing in Urdu (`اردو`): The Power of Unicode
Every time you type a message in Urdu, Sindhi, or Pashto on your phone, you are using Unicode. The old ASCII standard had no concept of characters like 'پ' or 'گ'. Without the massive character space provided by Unicode, the rich linguistic diversity of Pakistan would be invisible in the digital world. It is the silent engine behind digital multilingualism.
- Your CNIC and Unique Representation:
Your Computerised National Identity Card (CNIC) has a unique 13-digit number. While this number itself is stored as text, the principle is identical to binary representation. Each citizen is assigned a unique code that distinguishes them from over 220 million other Pakistanis. In the same way, in ASCII, the binary code `01000001` uniquely represents 'A' and nothing else. It’s all about using a logical system to assign a unique code to a unique entity.
- Streaming Music on Patari or Spotify:
When you listen to a classic Nusrat Fateh Ali Khan qawwali or a new song by Atif Aslam, you are listening to a compressed digital audio file. The difference between "standard quality" and "high quality" streaming is purely about the bits. A high-quality stream uses a higher bitrate (more bits per second), which means the original analogue sound was sampled with greater accuracy (higher bit depth or sample rate). More bits = more data = a more faithful reproduction of the original sound.
**Practice Problems**
- Calculation: Convert the denary number `214` into:
a) An 8-bit binary number.
b) A hexadecimal number.
*(Answer outline: Use repeated division by 2 for binary. Then group the binary into two nibbles to find the hex value, or use repeated division by 16.)*
- Explanation: Explain why hexadecimal notation is often used by programmers to represent binary numbers.
*(Answer outline: Mention that binary strings are long and prone to error for humans. State that one hex digit represents exactly 4 bits (a nibble). Conclude that hex is a more compact, less error-prone shorthand for binary.)*
- Application (File Size): A small icon for a mobile app is a bitmap image of 64 x 64 pixels. It uses an 8-bit colour depth. Calculate the file size in bytes. Show all your working.
*(Answer outline: Formula: W x H x Depth. `64 * 64 * 8` to get bits. Then divide by 8 to get bytes.)*
- Conceptual Understanding: A computer system uses a 5-bit binary code to represent the different spices available in a bazaar.
a) What is the maximum number of different spices that can be represented?
b) The code for 'Cinnamon' is `01101`. What is its denary value?
*(Answer outline: a) Use the `2ⁿ` formula: `2⁵`. b) Convert `01101` to denary using place values `16, 8, 4, 2, 1`.)*
- Problem Solving: A black and white image (1-bit colour depth) has a file size of 8 KB. If the image is a square, what is its resolution? (e.g., Width x Height).
*(Answer outline: Work backwards. Convert 8 KB to bits: `8 * 1024 * 8`. This gives the total number of pixels. Since it's a square, the width and height are the same. Find the square root of the total number of pixels.)*
Key Points to Remember
- 1All data in a computer, including text, images, and sound, is represented using the binary system.
- 2The binary system is a base-2 number system that uses only two digits: 1 and 0.
- 3In a computer's electronic circuits, a '1' represents an 'ON' state and a '0' represents an 'OFF' state.
- 4The denary system, used in everyday life, is a base-10 system that uses ten unique digits (0-9).
- 5In the denary system, the value of a digit is determined by its place value, which is a power of 10.
- 6Place values are read from right to left, starting with the base to the power of zero (e.g., 10⁰).
- 7A fundamental mathematical rule is that any number raised to the power of 0 is equal to 1.
- 8Abstraction is the concept of building complex layers of meaning, like words or pictures, on top of simple binary code.
- 9Computers group binary digits to represent more complex data like numbers, letters, and the colour of a pixel.
- 10At its lowest level, every digital file is simply a very long sequence of 1s and 0s.
Pakistan Example
Easypaisa & JazzCash Transactions
When you send Rs 1,000 via Easypaisa, your phone converts everything to binary. Your phone number (11 digits) is stored as binary. The amount 1000 in binary is 1111101000 (10 bits). The MPIN you enter gets converted to binary, encrypted (scrambled using complex binary operations), and sent over the network as electromagnetic signals representing 0s and 1s. Even the beep sound you hear is stored as binary samples. Millions of binary digits fly through Pakistan's mobile networks every second for just one transaction!
Quick Revision Infographic
Computer Science — Quick Revision
Binary & Data Representation
Key Concepts
Easypaisa & JazzCash Transactions
When you send Rs 1,000 via Easypaisa, your phone converts everything to binary. Your phone number (11 digits) is stored as binary. The amount 1000 in binary is 1111101000 (10 bits). The MPIN you enter gets converted to binary, encrypted (scrambled using complex binary operations), and sent over the network as electromagnetic signals representing 0s and 1s. Even the beep sound you hear is stored as binary samples. Millions of binary digits fly through Pakistan's mobile networks every second for just one transaction!