Information Representation

Jul 6, 2024

Lecture Notes: Information Representation

Introduction

  • Presenter: James, a computer science graduate turned teacher
  • Series focus: A-level computer science

Chapter 1: Information Representation

Learning Objectives

  • How computers use binary to represent numbers, text, images, and sound
  • Compression techniques for different file formats to reduce file size

Subtopic: Number Systems

Decimal System (Denary)

  • Base 10 system: 10 unique values (0-9)
  • Place value: Importance of digit position (e.g., 365: 5 is units, 6 is tens, 3 is hundreds)

Binary System

  • Base 2 system: Only two unique values (0 and 1)
  • Used due to electrical components representing two states (ON/OFF)
  • Transistors use binary switches to represent various data

Binary to Denary Conversion

  • Multiply digit value by place value and sum (e.g., binary 10101 = 1x16 + 0x8 + 1x4 + 0x2 + 1x1)

Byte and Nibble

  • 1 Byte: 8 bits
  • 1 Nibble: 4 bits (half-byte)

Hexadecimal System

  • Base 16 system: 16 unique values (0-9 and A-F)
  • Simplifies binary representation (e.g., 4 binary bits = 1 hexadecimal character)
  • Usage: Error codes, IP addresses, MAC addresses, HTML color codes

Converting Between Systems

Binary to Hexadecimal Conversion

  • Split binary into chunks of four, then convert chunks to hexadecimal

Denary to Binary Conversion

  • Divide the number by 2, record the remainder, and read remainders bottom-up

Hexadecimal to Denary

  • Multiply each digit by its place value (16^position) and sum

Representing Large Numbers

Decimal Prefixes

  • Kilo: 10^3 = 1,000

Binary Prefixes

  • Kibibyte (KiB): 2^10 = 1,024 bytes
  • Mebibyte (MiB): 1,024 KiB

Terminology and Conversions

  • Formula for conversions between bits, bytes, KiB, MiB, etc.
  • Examples of converting between these units

Two's Complement

  • Representing negative numbers in binary
  • Sign bit: Leftmost bit used for the sign (0 for positive, 1 for negative)
  • Examples: Converting positive/negative numbers using two's complement

Arithmetic in Binary

Addition

  • Follow borrowing rules but in binary (e.g., 1+1 = 10 in binary, carry the 1)

Subtraction

  • Borrowing in binary (e.g., 0-1, borrow from next column)

Overflow Problem

  • Extra bit generated that a register cannot handle, causing errors
  • Importance of detecting overflow and handling it

Representing Text

ASCII

  • American Standard Code for Information Interchange (ASCII): 7-bit code for characters

Unicode

  • UTF encoding systems: 1-byte, 2-byte, 3-byte, 4-byte codes
  • Variable length: Allows more characters to be represented

Representing Images

Vector Graphics

  • Defined by mathematical equations
  • Scalable without loss of quality

Bitmap Graphics

  • Made up of pixels, each pixel represented by bits
  • Color depth: Number of bits per pixel determines the number of colors
  • Resolution: Number of pixels in an image grid

File Size Calculations

  • Image size: Multiply resolution by color depth (in bits), then convert to bytes
  • Sound file size: Multiply sampling rate by sampling resolution and time, convert as needed

Compression Techniques

Lossless Compression

  • Run-length Encoding: Encodes repeated values by specifying the count
  • Huffman Encoding: Assigns shorter codes to more frequent characters

Lossy Compression

  • Some information lost to achieve higher compression
  • Techniques include reducing sample rate or color depth for images

Conclusion

  • Recap of key points: Number systems, conversions, text representation, images, sound, compression
  • Next steps: Transition to Chapter 2