Overview
This lecture introduces how computers represent and manipulate information such as numbers, text, images, and sound using binary and other number systems. It also covers file size calculations and compression techniques.
Number Systems & Conversion
- Computers use binary (base 2) to represent data due to their two-state electronic components.
- Decimal (denary) is base 10, with each digit’s value based on its position.
- Binary digits (bits): 8 bits = 1 byte, 4 bits = 1 nibble.
- Hexadecimal (base 16) uses digits 0-9 and letters A-F; each hex digit represents 4 binary bits.
- Convert binary to decimal by summing values with digit 1; decimal to binary by repeatedly dividing by 2 and collecting remainders.
- Convert binary to hex by grouping bits in sets of 4; add leading zeros if needed.
- Convert hex to decimal by multiplying each digit by its place value (16^n).
- Decimal to hex: repeatedly divide by 16, convert remainders >9 to A-F.
Storage Units & Prefixes
- Decimal prefixes (kilo, mega) are powers of 10; binary prefixes (kibi, mebi) are based on 1024.
- 1 KB = 1024 bytes, 1 MB = 1024 KB, etc.
- Convert between units by dividing or multiplying by 8, 1024 as appropriate.
Signed Numbers & Binary Arithmetic
- Two's complement allows representation of negative numbers in binary; highest bit is the sign bit.
- Binary addition and subtraction use carries and borrows similar to decimal, but only with 0 and 1.
- Overflow occurs when results exceed the register’s bit limit.
Binary Coded Decimal (BCD)
- Each decimal digit is separately encoded in binary; two main types: uncompressed (1 digit/byte) and packed (2 digits/byte).
- When adding BCD, invalid results require adjustment by adding 6 (0110).
Text Representation
- ASCII uses 7 or 8 bits to encode English characters and some symbols.
- Unicode (e.g., UTF-8) supports many more characters using variable-length encoding (1–4 bytes), utilizing specific starting byte patterns.
Image Representation
- Vector graphics use mathematical equations for objects—scalable without loss.
- Bitmap images are grids of pixels, with color determined by color depth (bits per pixel).
- Color depth: more bits allow more colors; standard RGB uses 8 bits each for red, green, and blue.
- Image resolution = width × height in pixels; higher resolution means better quality.
- Image size formula: width × height × color depth / 8 = bytes.
Sound Representation
- Sound is digitized by sampling amplitude at set intervals (sampling rate).
- Sampling resolution = bits per sample; higher resolution allows finer amplitude distinction.
- File size formula: sampling rate × bit depth × duration (sec) × channels / 8 = bytes.
Compression Techniques
- Lossless compression (e.g., Run Length Encoding, Huffman coding) reduces file size without data loss.
- Lossy compression reduces file size by discarding less important information (e.g., similar colors, sound differences).
Key Terms & Definitions
- Bit — Smallest unit of data (0 or 1).
- Byte — 8 bits.
- Nibble — 4 bits.
- Two's Complement — Binary method for representing signed integers.
- ASCII — Code for representing English characters in binary.
- Unicode — Universal character encoding, supports many scripts.
- Vector Graphic — Image format using shapes and equations.
- Bitmap — Image format using a grid of colored pixels.
- Color Depth — Number of bits per pixel for color information.
- Sampling Rate — Number of sound samples per second.
- Run Length Encoding (RLE) — Lossless compression summarizing repeated values.
- Huffman Coding — Compression assigning shorter codes to frequent symbols.
Action Items / Next Steps
- Practice converting between binary, decimal, and hexadecimal.
- Review ASCII and Unicode tables.
- Calculate file sizes for images and sound using provided formulas.
- Complete assigned reading on lossless and lossy compression methods.