1. Introduction to Number Systems
In computing, data is represented in different number systems (or bases), depending on the context. The most common systems are:
| Number System | Base | Digits Used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | 1010 |
| Denary (Decimal) | 10 | 0–9 | 42 |
| Hexadecimal | 16 | 0–9, A–F | 2F |
- Binary: Used by all digital devices.
- Denary: What humans use daily.
- Hexadecimal: Programmer-friendly shorthand for binary.
2. Binary (Base-2)
Binary only uses 0 and 1. Each digit is called a bit.
8 bits = 1 byte.
Computers use binary because internal components (transistors) operate in two states:
- ON (1)
- OFF (0)
Binary to Denary Conversion
Each binary digit represents a power of 2, starting from the right.
Example: Convert 1011 to decimal.
| Bit Position | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| Binary Digit | 1 | 0 | 1 | 1 |
| Calculation | 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11 |
3. Denary (Base-10)
The standard system for humans. Uses digits 0–9.
Denary to Binary Conversion
Divide the number by 2 repeatedly. Record remainders.
Example: Convert 13 to binary.
| Division | Quotient | Remainder |
|---|---|---|
| 13 ÷ 2 | 6 | 1 (LSB) |
| 6 ÷ 2 | 3 | 0 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 (MSB) |
Binary = 1101
4. Hexadecimal (Base-16)
Hex uses digits 0–9 and A–F (A = 10, F = 15).
Why use hex?
- Shorter than binary
- Easier to read/debug
- Maps directly to binary (1 hex digit = 4 bits)
Hexadecimal to Denary Example
Convert 2F to decimal:
| Digit | Position | Value |
|---|---|---|
| 2 | 16¹ | 2×16 = 32 |
| F=15 | 16⁰ | 15×1 = 15 |
Total = 32 + 15 = 47
Binary to Hex Conversion
Split into 4-bit nibbles.
Binary: 11010110 → 1101 0110
→ 1101 = D, 0110 = 6
Hex: D6
5. Quick Conversion Table
| Denary | Binary (8-bit) | Hex |
|---|---|---|
| 0 | 00000000 | 0 |
| 5 | 00000101 | 5 |
| 10 | 00001010 | A |
| 15 | 00001111 | F |
| 255 | 11111111 | FF |
6. Why Do Programmers Use Hexadecimal?
1. Compact Representation
Binary: 1101001110101101
Hex: D3AD
2. Easy to Read
Common in memory addresses, color codes (#FF5733), machine-level debugging.
3. Direct Binary Mapping
Each hex digit maps to exactly 4 bits, making conversion straightforward.
4. Historical Use
Hex has long been used in assembly language and low-level systems for simplicity.
7. Compression Techniques: Lossy vs. Lossless
With large files (images, audio, video), compression helps reduce file size.
What Is Compression?
Compression reduces the number of bits needed to store or transmit data. This:
- Saves storage space
- Reduces transfer time
- Optimizes performance
Two Main Types:
| Type | Data Loss | Common Use Cases |
|---|---|---|
| Lossless | None | Text, code, PNGs |
| Lossy | Some data discarded | Photos, music, video |
Lossless Compression
Original data is preserved. Can be decompressed to the exact original.
Common Techniques:
- Run-Length Encoding (RLE)
Example:"AAAABBBCC"→"4A3B2C" - Huffman Coding
Frequently used characters get shorter binary codes.
File Formats:
.zip, .png, .flac, .gif
Lossy Compression
Data is permanently removed. Ideal when perfect accuracy isn’t needed.
Techniques:
- JPEG – Compresses image detail
- MP3 – Removes inaudible frequencies
- MP4 – Drops unnecessary video frames
File Formats:
.jpg, .mp3, .mp4, .avi
8. File Size Calculations
Understanding file sizes helps explain why compression is needed.
Image File Size:
Formula:
File Size = Width × Height × Colour Depth
Example:
1920 × 1080 @ 24 bits =
1920 × 1080 × 24 = 49,766,400 bits ≈ 5.96 MB
Audio File Size:
Formula:
File Size = Sample Rate × Bit Depth × Channels × Duration
Example:
44,100 Hz, 16-bit, stereo, 60 sec =
44100 × 16 × 2 × 60 = 84,672,000 bits ≈ 10.58 MB
9. Bitmap vs. Vector Images
| Feature | Bitmap Images | Vector Images |
|---|---|---|
| Structure | Pixels | Shapes & paths |
| Scaling | Pixelates on zoom | Scales without loss |
| Common Uses | Photos | Logos, diagrams |
| File Types | .bmp, .jpg, .png | .svg, .pdf, .eps |
Bitmap Example: A photo becomes blurry when zoomed.
Vector Example: A logo stays crisp on a billboard.
10. Summary & Key Takeaways
- Binary is how computers store data (1s and 0s).
- Denary is our everyday numbering system.
- Hexadecimal is a compact, programmer-friendly way to represent binary.
- Lossless compression preserves original data—used for accuracy.
- Lossy compression reduces file size significantly—used for media.
- You should be able to convert between systems, understand file size formulas, and explain bitmap vs vector images.
Final Thought:
Hex is like “shorthand binary”—compact, human-friendly, and efficient.
Compression makes modern media and storage practical.
Below is a detailed presentation for this chapter. Use it to study from slides.
