Data Representation
How computers represent numbers, text, images, and sound using binary and hexadecimal systems.
### Introduction to Data Representation
At the most fundamental level, a computer is an electronic device made of billions of tiny switches. Each switch can be in one of two states: on or off. We represent these two states using the digits 1 (on) and 0 (off). This two-digit number system is called binary (base-2), and it is the language of all digital computers. Every piece of information—from the text in this document to a high-definition video—is stored and processed as vast sequences of these 0s and 1s.
### Units of Data Storage
The smallest unit of data is a bit (binary digit), which can be either a 0 or a 1. To represent more complex information, bits are grouped together.
Exam Trap: Be careful with units! Internet speeds are often measured in **megabits per second (Mbps)**, while file sizes are in **megabytes (MB)**. Since 1 byte = 8 bits, a 100 Mbps connection will download a 100 MB file in approximately 8 seconds, not 1 second.
### Number Systems
Computers use binary, but humans find it easier to work with decimal (denary) and hexadecimal systems.
#### Binary (Base-2)
Uses only two digits: 0 and 1. Each position represents a power of 2, starting from the right (2⁰, 2¹, 2², etc.).
#### Denary (Decimal, Base-10)
The number system we use daily, with digits 0-9.
#### Hexadecimal (Base-16)
Uses 16 symbols: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Hexadecimal is used by programmers as a human-friendly shorthand for binary because it is very compact.
### Representing Text: ASCII and Unicode
Computers store text by assigning a unique binary code to each character.
### Representing Images: Pixels and Bitmaps
Bitmap images are stored as a grid of tiny dots called pixels (picture elements).
### Representing Sound: Sampling
Sound in the real world is a continuous analogue wave. To store it on a computer, it must be converted into a digital format through a process called sampling.
Key Points to Remember
- 1Binary: base 2, each bit doubles in value
- 2Hex: base 16, one digit = 4 bits
- 3Image size = pixels × colour depth ÷ 8 bytes
- 4Sound: sample rate × bit depth × duration = file size
Pakistan Example
NADRA's Database — Binary Data for 220 Million Pakistanis
Every CNIC in Pakistan is stored digitally by NADRA. Your name is stored in ASCII/Unicode, your photo in pixels (binary colour values), and your fingerprint as a compressed binary file. NADRA's B-grade ID card photo might be 200×200 pixels at 24-bit colour = 200×200×24 = 960,000 bits = 120,000 bytes = ~117 KB before compression. Real binary maths applied to national data.
Quick Revision Infographic
Computer Science — Quick Revision
Data Representation
Key Concepts
Formulas to Know
one digit = 4 bitscolour depth ÷ 8 bytesduration = file sizeNADRA's Database — Binary Data for 220 Million Pakistanis
Every CNIC in Pakistan is stored digitally by NADRA. Your name is stored in ASCII/Unicode, your photo in pixels (binary colour values), and your fingerprint as a compressed binary file. NADRA's B-grade ID card photo might be 200×200 pixels at 24-bit colour = 200×200×24 = 960,000 bits = 120,000 bytes = ~117 KB before compression. Real binary maths applied to national data.