1.1 Data Representation
Binary Magnitudes and Prefixes
Binary vs Decimal Prefixes
Understanding the difference between binary and decimal prefixes is crucial, especially when dealing with storage capacities.
| Binary Prefix | Value | Decimal Prefix | Value |
|---|---|---|---|
| Kibi (Ki) | 2¹⁰ = 1,024 | Kilo (K) | 10³ = 1,000 |
| Mebi (Mi) | 2²⁰ = 1,048,576 | Mega (M) | 10⁶ = 1,000,000 |
| Gibi (Gi) | 2³⁰ = 1,073,741,824 | Giga (G) | 10⁹ = 1,000,000,000 |
| Tebi (Ti) | 2⁴⁰ = 1,099,511,627,776 | Tera (T) | 10¹² = 1,000,000,000,000 |
Why this matters:
- Operating systems often report storage using binary prefixes (e.g., Windows shows 1 GiB as “1 GB” even though it’s actually 1.074 GB)
- Hard drive manufacturers typically use decimal prefixes to make capacities sound larger
- A “500 GB” hard drive actually has 500 × 10⁹ bytes ≈ 465.66 GiB of actual storage
Number Systems
1. Denary (Base-10)
- Uses digits 0-9
- Each place value is a power of 10
- Example: 345₁₀ = (3 × 10²) + (4 × 10¹) + (5 × 10⁰)
2. Binary (Base-2)
- Uses digits 0 and 1 (bits)
- Each place value is a power of 2
- Fundamental to all computer operations
- Example: 1011₂ = (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11₁₀
3. Hexadecimal (Base-16)
- Uses digits 0-9 and letters A-F
- A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
- Each place value is a power of 16
- Example: 2F₁₆ = (2 × 16¹) + (15 × 16⁰) = 32 + 15 = 47₁₀
Why use hexadecimal?
- More compact representation than binary
- Easier for humans to read and remember
- Each hex digit represents exactly 4 bits (a nibble)
- Commonly used in memory addresses, MAC addresses, colour codes
4. Binary Coded Decimal (BCD)
- Each denary digit is represented by its 4-bit binary equivalent
- Not an efficient use of space but useful for displays and precise decimal calculations
| Denary | BCD |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
Example: 39₁₀ in BCD = 0011 1001 (each digit encoded separately)
Note: 1010, 1011, 1100, 1101, 1110, 1111 are invalid in BCD
Number System Conversions
Binary to Denary
Multiply each bit by its place value (powers of 2) and sum.
Example: Convert 1101₂ to denary
1 1 0 1
2³ 2² 2¹ 2⁰
8 + 4 + 0 + 1 = 13₁₀
Denary to Binary
Divide repeatedly by 2, reading remainders from bottom to top.
Example: Convert 25₁₀ to binary
25 ÷ 2 = 12 remainder 1 ↑
12 ÷ 2 = 6 remainder 0 |
6 ÷ 2 = 3 remainder 0 |
3 ÷ 2 = 1 remainder 1 |
1 ÷ 2 = 0 remainder 1 |
Reading upwards: 11001₂
Binary to Hexadecimal
Group binary digits into groups of 4 (from right), convert each group.
Example: Convert 10110111₂ to hexadecimal
1011 0111
↓ ↓
B 7
Therefore: 10110111₂ = B7₁₆
Hexadecimal to Binary
Convert each hex digit to its 4-bit binary equivalent.
Example: Convert 3F₁₆ to binary
3 F
↓ ↓
0011 1111
Therefore: 3F₁₆ = 00111111₂
Hexadecimal to Denary
Multiply each digit by its place value (powers of 16) and sum.
Example: Convert A3₁₆ to denary
A 3
16¹ 16⁰
10 × 16¹ = 160
3 × 16⁰ = 3
Total = 163₁₀
Denary to Hexadecimal
Divide repeatedly by 16, reading remainders from bottom to top.
Example: Convert 200₁₀ to hexadecimal
200 ÷ 16 = 12 remainder 8 ↑
12 ÷ 16 = 0 remainder 12 (C) |
Reading upwards: C8₁₆
Binary Addition and Subtraction
Binary Addition Rules
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Example: Add 1011₂ (11₁₀) and 1101₂ (13₁₀)
1 0 1 1
+ 1 1 0 1
-----------
1 1 0 0 0
Check: 11 + 13 = 24, and 11000₂ = 24₁₀ ✓
Binary Subtraction
Can be performed using two’s complement (see below) or direct borrowing:
Example: Subtract 0110₂ (6₁₀) from 1010₂ (10₁₀)
1 0 1 0
- 0 1 1 0
-----------
0 1 0 0
Check: 10 – 6 = 4, and 0100₂ = 4₁₀ ✓
Representing Negative Binary Numbers
Sign and Magnitude
- The leftmost bit (MSB) represents the sign: 0 = positive, 1 = negative
- Remaining bits represent the magnitude
Example with 4 bits:
- +5 = 0101
- -5 = 1101
Problems:
- Two representations for zero: 0000 (+0) and 1000 (-0)
- Arithmetic is complicated
One’s Complement
- Positive numbers are represented normally
- Negative numbers are obtained by inverting all bits (0→1, 1→0)
Example with 4 bits:
- +5 = 0101
- -5 = 1010 (invert all bits)
Problems:
- Still has two zeros: 0000 and 1111
- End-around carry needed in arithmetic
Two’s Complement (Most Important!)
- Positive numbers are represented normally
- Negative numbers are obtained by:
- Write the positive number in binary
- Invert all bits (one’s complement)
- Add 1 to the result
Example: Find -5 in two’s complement (4 bits)
Step 1: +5 = 0101
Step 2: Invert = 1010
Step 3: Add 1 = 1011
Therefore: -5 = 1011₂
Converting back: 1011₂
Step 1: Subtract 1 = 1010
Step 2: Invert = 0101 = +5
Therefore: 1011₂ = -5
Range for n-bit two’s complement:
- Minimum: -2ⁿ⁻¹
- Maximum: 2ⁿ⁻¹ – 1
For 4 bits: -8 to +7
For 8 bits: -128 to +127
For 16 bits: -32,768 to +32,767
Advantages of two’s complement:
- Only one representation for zero (0000)
- Addition works the same for positive and negative numbers
- No special hardware needed for subtraction
Binary Addition with Two’s Complement
Example: Add +5 (0101) and -3 (1101)
First, find -3:
+3 = 0011
Invert = 1100
Add 1 = 1101
Now add:
0101 (+5)
+ 1101 (-3)
-----------
10010
↑
Discard carry beyond 4 bits
-----------
Result: 0010 = +2 ✓
Overflow
What is overflow?
Overflow occurs when the result of an arithmetic operation is too large to fit in the available number of bits.
When does it happen?
- When adding two positive numbers and the result becomes negative
- When adding two negative numbers and the result becomes positive
- When the carry into the sign bit differs from the carry out of the sign bit
Example with 4 bits (range -8 to +7):
Adding +5 (0101) and +4 (0100):
0101 (+5)
+ 0100 (+4)
-----------
1001
Result 1001 = -7 in two’s complement (incorrect!)
Overflow has occurred because 5 + 4 = 9, which exceeds +7.
Detecting overflow:
If carry into MSB ≠ carry out of MSB, overflow has occurred.
Practical Applications
Binary Coded Decimal (BCD) Applications
- Digital Displays
- Calculators, digital clocks, and measuring instruments
- Each digit can be displayed independently
- Financial Systems
- Avoids rounding errors in decimal calculations
- Used in banking and accounting software
- Real-time Clocks
- Time is naturally represented in decimal (hours, minutes, seconds)
Hexadecimal Applications
- Memory Addresses
- Debuggers show memory addresses in hex
- Example: 0x7FFF is easier to read than 0111111111111111
- MAC Addresses
- 48-bit addresses shown as 12 hex digits
- Example: 00:1A:2B:3C:4D:5E
- Colour Codes in Web Design
- RGB colours in hex: #FF0000 = red
- #FFFFFF = white, #000000 = black
- Assembly Language and Machine Code
- More readable than binary
- Each hex digit represents exactly 4 bits
- Error Codes
- Blue Screen of Death shows error codes in hex
- Memory dumps use hexadecimal
Character Representation
ASCII (American Standard Code for Information Interchange)
Standard ASCII (7-bit)
- Uses 7 bits to represent 128 characters
- Includes:
- Uppercase letters A-Z (65-90)
- Lowercase letters a-z (97-122)
- Digits 0-9 (48-57)
- Punctuation marks
- Control characters (0-31)
Example ASCII codes:
- ‘A’ = 65₁₀ = 1000001₂ = 41₁₆
- ‘a’ = 97₁₀ = 1100001₂ = 61₁₆
- ‘0’ = 48₁₀ = 0110000₂ = 30₁₆
- Space = 32₁₀ = 0100000₂ = 20₁₆
Extended ASCII (8-bit)
- Uses 8 bits to represent 256 characters
- First 128 characters same as standard ASCII
- Additional 128 characters include:
- Accented letters (é, ñ, ü)
- Special symbols (£, ©, ®)
- Line drawing characters
- Mathematical symbols
Problem: Different manufacturers used different extended character sets → incompatibility issues
Unicode
Why Unicode was needed:
- ASCII only supports Western languages
- Need to represent all world’s writing systems
- Single unified standard
Key features:
- Can use 16, 24, or 32 bits per character
- Over 140,000 characters supported
- Includes emojis and ancient scripts
- First 128 characters match ASCII for backward compatibility
Common encodings:
- UTF-8: Variable length (1-4 bytes), backward compatible with ASCII
- UTF-16: Uses 2 or 4 bytes
- UTF-32: Fixed 4 bytes per character
Examples:
- ‘A’ = U+0041 (same as ASCII)
- ‘€’ (euro symbol) = U+20AC
- ‘中’ (Chinese character) = U+4E2D
- ‘😊’ (emoji) = U+1F60A
1.2 Multimedia
Graphics
Bitmap Images
Key Terminology:
| Term | Definition |
|---|---|
| Pixel | Picture element; the smallest addressable element in a display device |
| File Header | Contains metadata about the image (dimensions, colour depth, file type) |
| Image Resolution | The number of pixels in an image (width × height) |
| Screen Resolution | The number of pixels a monitor can display |
| Colour Depth / Bit Depth | Number of bits used to represent each pixel’s colour |
How Bitmap Data is Encoded:
- Image divided into a grid of pixels
- Each pixel stores colour information as binary data
- Number of bits per pixel = colour depth
- Header contains dimensions and other metadata
- Pixel data stored sequentially (row by row)
File Size Calculation for Bitmap Images
Formula:
File Size = Image Resolution × Colour Depth
= (Width × Height) × Colour Depth
Example 1: Calculate file size for 1024 × 768 image with 24-bit colour
Resolution = 1024 × 768 = 786,432 pixels
Colour depth = 24 bits = 3 bytes
File size = 786,432 × 3 = 2,359,296 bytes
= 2,359,296 ÷ 1024 = 2,304 KiB
= 2,304 ÷ 1024 = 2.25 MiB
Example 2: 1920 × 1080 (Full HD) with 32-bit colour
Resolution = 1920 × 1080 = 2,073,600 pixels
Colour depth = 32 bits = 4 bytes
File size = 2,073,600 × 4 = 8,294,400 bytes
= 8,294,400 ÷ 1024 = 8,100 KiB
= 8,100 ÷ 1024 = 7.91 MiB
Effects of Changing Elements
| Change | Effect on Quality | Effect on File Size |
|---|---|---|
| Increase image resolution | Higher quality, more detail | Increases significantly |
| Decrease image resolution | Lower quality, pixelation | Decreases significantly |
| Increase colour depth | More colours, smoother gradients | Increases |
| Decrease colour depth | Fewer colours, banding | Decreases |
Colour Depth Examples:
- 1-bit: 2 colours (black and white)
- 4-bit: 16 colours
- 8-bit: 256 colours
- 16-bit: 65,536 colours (High Colour)
- 24-bit: 16.7 million colours (True Colour)
- 32-bit: 16.7 million colours + alpha channel (transparency)
Vector Graphics
How Vector Graphics are Encoded:
- Images are stored as mathematical formulas and geometric objects
- Each object has properties and is stored in a drawing list
Key Terminology:
| Term | Definition |
|---|---|
| Drawing Object | A geometric shape (line, circle, rectangle, polygon) |
| Property | Attributes of an object (colour, line thickness, fill, position) |
| Drawing List | Collection of all objects that make up the image |
Common Vector Objects and Their Properties:
Circle:
- Centre coordinates (x, y)
- Radius
- Fill colour
- Outline colour
- Outline thickness
Rectangle:
- Top-left corner (x, y)
- Width, Height
- Fill colour
- Outline colour
- Rotation angle
Line:
- Start point (x1, y1)
- End point (x2, y2)
- Colour
- Thickness
Vector File Formats:
- SVG (Scalable Vector Graphics)
- EPS (Encapsulated PostScript)
- AI (Adobe Illustrator)
- CDR (CorelDRAW)
Bitmap vs Vector Graphics: Comparison
| Feature | Bitmap | Vector |
|---|---|---|
| Composition | Grid of pixels | Mathematical formulas |
| Scaling | Loses quality when enlarged (pixelates) | Can be scaled infinitely without quality loss |
| File Size | Large, depends on resolution | Small, depends on complexity |
| Editing | Pixel-level editing possible | Edit objects and properties |
| Realism | Excellent for photographs | Better for illustrations, logos |
| Conversion | Can be converted to vector (tracing) | Can be converted to bitmap (rasterisation) |
| Common Uses | Photos, scanned images | Logos, diagrams, fonts, illustrations |
Justifying Image Type for a Given Task
Choose Bitmap when:
- Working with photographs or realistic images
- Need complex colour variations and gradients
- Image source is from a camera or scanner
- Need pixel-level editing
- Web photos and digital art
Choose Vector when:
- Creating logos that need to scale to different sizes
- Designing diagrams, flowcharts, or technical drawings
- Creating fonts and text
- Image will be used at multiple resolutions
- File size needs to be minimised
- Need precise, clean lines
Sound
How Sound is Represented and Encoded
Key Terminology:
| Term | Definition |
|---|---|
| Analogue Data | Continuous signal that varies over time |
| Digital Data | Discrete samples representing the analogue signal |
| Sampling | Process of converting analogue to digital by taking measurements at intervals |
| Sampling Rate | Number of samples taken per second (measured in Hz or kHz) |
| Sampling Resolution | Number of bits used to store each sample (bit depth) |
The Analogue-to-Digital Conversion Process
- Sound waves (analogue) are picked up by a microphone
- Sampling: Measurements taken at regular intervals (sampling rate)
- Quantisation: Each sample assigned a digital value (sampling resolution)
- Encoding: Digital values stored as binary data
Example:
- CD quality: 44.1 kHz sampling rate, 16-bit resolution
- 44,100 samples per second, each stored in 16 bits
File Size Calculation for Sound
Formula:
File Size = Sampling Rate × Sampling Resolution × Duration × Channels
Example: Calculate file size for 3-minute stereo song at CD quality
Sampling rate = 44,100 Hz
Resolution = 16 bits = 2 bytes
Duration = 3 minutes = 180 seconds
Channels = 2 (stereo)
File size = 44,100 × 2 × 180 × 2
= 44,100 × 720
= 31,752,000 bytes
= 31,752,000 ÷ 1024 = 31,008 KiB
= 31,008 ÷ 1024 = 30.28 MiB
Impact of Changing Sampling Parameters
Increasing Sampling Rate:
- More accurate representation of high frequencies
- Higher quality recording
- Larger file size
Increasing Sampling Resolution:
- More precise amplitude values
- Better dynamic range (quieter and louder sounds)
- Reduced quantisation noise
- Larger file size
Nyquist Theorem:
To accurately represent a frequency, you must sample at at least twice that frequency. This is why CD quality (44.1 kHz) can represent up to 22.05 kHz (just above human hearing range of 20 kHz).
| Quality | Sampling Rate | Resolution | Use Case |
|---|---|---|---|
| Telephone | 8 kHz | 8-bit | Voice calls |
| Radio | 22.05 kHz | 8-bit | AM-quality audio |
| CD | 44.1 kHz | 16-bit | Music albums |
| DVD | 48 kHz | 16/24-bit | Movies |
| Studio | 96 kHz | 24/32-bit | Professional recording |
1.3 Compression
Need for Compression
Why compress files?
- Reduce storage space requirements
- Faster file transfer over networks
- Reduce bandwidth usage when streaming
- Make more efficient use of limited resources
- Enable storage of more files on devices
Examples where compression is essential:
- Streaming video (Netflix, YouTube)
- Downloading software
- Sending email attachments
- Storing photos on phones
- Music streaming services
- Video conferencing
Lossy vs Lossless Compression
Lossless Compression
How it works:
- Reduces file size without losing any original data
- Original file can be perfectly reconstructed
- Works by identifying and eliminating redundancy
Common methods:
- Run-Length Encoding (RLE)
- Huffman coding
- LZW compression
Advantages:
- No quality loss
- Original data preserved exactly
- Essential for text, programs, critical data
Disadvantages:
- Compression ratio limited (typically 2:1 to 4:1)
- Less effective than lossy for some media types
Lossy Compression
How it works:
- Permanently removes some data considered less important
- Original cannot be perfectly reconstructed
- Explores limitations of human perception
Advantages:
- Much higher compression ratios (10:1 to 100:1)
- Smaller file sizes
- Good for media where perfect reproduction isn’t needed
Disadvantages:
- Permanent quality loss
- Cannot recover original data
- Visible/audible artefacts at high compression
Run-Length Encoding (RLE)
How RLE works:
- Replaces repeated consecutive characters with a count and the character
- Works well for images with large areas of same colour
- Simple lossless compression method
Text Example:
Original: "AAAABBBCCDAA"
Encoded: "4A3B2C1D2A"
Compression: 12 characters → 10 characters
Bitmap Image Example:
Original pixels: 5 white, 3 black, 4 white
Without RLE: WWWWWBBBWWWW
With RLE: 5W3B4W
Advantages of RLE:
- Simple to implement
- Fast compression and decompression
- Effective for simple images (icons, line art, text)
Disadvantages:
- Inefficient for complex images with frequent changes
- Can actually increase file size for “noisy” data
Compression by File Type
Text File Compression
Methods used:
- Run-Length Encoding (RLE)
- Dictionary-based compression (LZW)
- Huffman coding (variable-length codes)
How it works:
- Find repeated patterns or words
- Replace with shorter references
- Build dictionary of common sequences
Example: “the cat sat on the mat”
- “the” appears twice → store once, reference twice
- Common in ZIP, gzip formats
Bitmap Image Compression
Lossless methods:
- RLE: Effective for images with large uniform areas
- LZW: Used in GIF and TIFF formats
- PNG: Uses DEFLATE algorithm (combination of LZ77 and Huffman)
Lossy methods:
- JPEG:
- Divides image into 8×8 blocks
- Applies Discrete Cosine Transform (DCT)
- Quantisation (removes less visible detail)
- Can achieve 10:1 to 20:1 compression
Vector Graphic Compression
How vectors compress well:
- Already stored as compact mathematical formulas
- File size depends on complexity, not dimensions
- SVG files can be compressed with gzip (SVGZ)
Compression methods:
- Remove unnecessary whitespace
- Simplify paths (reduce number of points)
- Use relative instead of absolute coordinates
- Reuse definitions (symbols, patterns)
Sound File Compression
Lossless audio:
- FLAC (Free Lossless Audio Codec)
- ALAC (Apple Lossless)
- Typically 2:1 to 3:1 compression
Lossy audio:
- MP3 (MPEG-1 Audio Layer 3)
- AAC (Advanced Audio Coding)
- Uses psychoacoustic models to remove inaudible sounds
- Typical compression: 10:1 (CD quality → 1.4 Mbps → 128 kbps)
How lossy audio compression works:
- Analysed in frequency domain
- Masking effects applied (louder sounds hide quieter ones)
- Less audible frequencies given fewer bits
- Result encoded efficiently
Justifying Compression Methods
When to use Lossless Compression:
- Text documents and source code
- Executable programs
- Spreadsheets with critical data
- Medical images (X-rays, MRI scans)
- Archival purposes
- When any data loss is unacceptable
When to use Lossy Compression:
- Streaming video (Netflix, YouTube)
- Music streaming (Spotify, Apple Music)
- Sharing photos on social media
- Video calls (Zoom, Skype)
- When bandwidth/storage is limited
- When slight quality loss is acceptable
Summary Checklist for Assessment Objectives
AO1 (Knowledge) – You should be able to:
- ✓ Define binary prefixes (kibi, mebi, gibi, tebi)
- ✓ Describe different number systems
- ✓ Explain BCD and two’s complement
- ✓ Define pixel, resolution, colour depth
- ✓ Define sampling, sampling rate, resolution
- ✓ Explain need for compression
- ✓ Define lossy and lossless compression
- ✓ Describe RLE
AO2 (Application) – You should be able to:
- ✓ Convert between number bases
- ✓ Perform binary addition/subtraction
- ✓ Identify overflow
- ✓ Calculate bitmap file sizes
- ✓ Calculate sound file sizes
- ✓ Apply RLE to given data
- ✓ Justify compression method for given scenario
AO3 (Design/Evaluation) – You should be able to:
- ✓ Evaluate effects of changing image parameters
- ✓ Compare bitmap vs vector for tasks
- ✓ Evaluate impact of changing sound parameters
- ✓ Justify image/sound format choices
- ✓ Compare lossy vs lossless for situations
