Data Storage and Representation Study Notes
Bits and Their Storage
Definition of a Bit:
Inside modern digital computers, information is encoded as patterns of s and s called bits (short for binary digits).
Bits are fundamentally abstract symbols whose meaning is determined by the application context. Bit patterns can represent numeric values, alphabetic characters, punctuation marks, images, or audio signals.
Boolean Operations:
Boolean operations manipulate true/false values, where represents
falseand representstrue. Named in honor of mathematician George Boole (–), a pioneer in mathematical logic.AND Operation: Combines two inputs. Produces an output of if and only if both inputs are ; otherwise, the output is . Represents compound statements of the form (e.g., "Kermit is a frog AND Miss Piggy is an actress").
OR Operation: Combines two inputs. Produces an output of if at least one input is ; produces only when both inputs are . Represents compound statements of the form
XOR (Exclusive OR) Operation: Combines two inputs. Produces an output of if one input is and the other is (i.e., when inputs differ). Produces if both inputs are identical.
NOT Operation: Accepts a single input and inverts it. A input yields a output, and a input yields a output (e.g., transforming "Fozzie is a bear" into "Fozzie is not a bear").

Gates and Flip-Flops:
Gates: Physical devices that compute Boolean operations given input signals. Gates can be built from gears, mechanical relays, optical devices, or semiconductor transistors in electronic circuits (where and are represented by distinct voltage levels).

Flip-Flops: Fundamental building blocks of computer memory circuits that store a single bit.
A flip-flop holds an output state of or until a pulse on an input line shifts its state.
In a standard flip-flop circuit composed of an OR gate, an AND gate, and a NOT gate, placing a temporary on the upper input forces the persistent output state to .
Placing a temporary on the lower input forces the persistent output state to 0$.\n\n\n\n\n\n - **Step-by-Step State Transition (Setting Output to 1)**:\n 1. A temporary 10.\n 2. The upper 11.\n 3. The NOT gate converts the lower 011.\n 4. The AND gate outputs 1, which feeds back into the second input of the OR gate.\n 5. This feedback loop holds the OR gate output at 10$.
Abstraction and Hierarchy:
Flip-flops can be constructed using alternative gate configurations (such as cross-coupled NOR or NAND gates) while maintaining identical external functional properties.
Engineers use lower-level circuits as abstract building blocks to construct higher-level, complex integrated systems without needing to re-evaluate internal component details.

Very Large-Scale Integration (VLSI): Manufacturing technology that fabricates millions of electronic components and flip-flops onto a single silicon semiconductor wafer (chip).
Hexadecimal Notation:
Bit patterns are called bit strings or bit streams. Reading long binary strings is prone to human error.
Hexadecimal notation uses a single character to represent a ‐bit pattern (nibble).
Since computer bit strings generally have lengths in multiples of four, hexadecimal provides a concise representation (‐bit pattern reduces to hexadecimal digits).

Conversion Mapping Table:
0000=00001=10010=20011=30100=40101=50110=60111=71000=81001=91010=A1011=B1100=C1101=D1110=E1111=F
Example:
10110101splits into1011(B) and0101(5), yieldingB5. The ‐bit pattern1010010011001000maps toA4C8.
Main Memory
Memory Organization:
Main memory is a large reservoir of addressable circuitry organized into small units called cells.
Standard cell size is ().
Bit Ordering within a Cell:
Left end: High-order end / Most significant bit (MSB).
Right end: Low-order end / Least significant bit (LSB).

Addressing System:
Each cell is assigned a unique numeric address, numbered sequentially starting from .
Ordering allows multi-byte data (e.g., integers) to be stored across consecutive memory cells.

Memory Access Operations:
Read Operation: Retrieves the bit pattern stored at a specified address without modifying the contents.
Write Operation: Overwrites the cell at a specified address with a new bit pattern.
Random Access Memory (RAM): Memory architecture allowing individual cells to be accessed directly and independently in any arbitrary sequence.
Dynamic RAM (DRAM): Stores bits as tiny electric charges that decay rapidly. Requires dynamic refresh circuits to repeatedly recharge cells multiple times per second.
Synchronous DRAM (SDRAM): Incorporates synchronized timing controls to accelerate memory retrieval speeds.
Measuring Memory Capacity:
Computer memory capacities are designed around powers of two ().
Capacity Units:
Kilobyte (): ().
Megabyte (): ( or ).
Gigabyte (): ( or ).
Terabyte (): ( or ).
Standardized IEC Binary Prefixes:
To resolve ambiguity with decimal metric prefixes (, ), standards organizations introduced terms: kibibyte (), mebibyte (), gibibyte (), and tebibyte () to explicitly denote powers of 1024$.\n\n# Mass Storage Systems\n\n- **Overview and Comparison with Main Memory**:\n - Mass storage (secondary storage) includes magnetic disks, optical discs, flash drives, and solid-state drives.\n - Advantages: Non-volatility, massive storage volume, lower cost per bit, and removable physical media capability.\n - Disadvantages: Mechanical motion systems introduce significant latency compared to pure electronic RAM circuitry.\n\n- **Magnetic Systems**:\n - **Hard Disk Drives (HDD)**: Utilize rigid spinning platters coated with magnetic film.\n - **Platters and Tracks**: Read/write heads hover above or below spinning platters, tracing concentric rings called **tracks**.\n - **Cylinders**: The set of aligned tracks across all platter surfaces at a single read/write arm position.\n - **Sectors**: Tracks are divided into continuous arcs called sectors. Each sector stores a fixed block of bits (typically 512\,bytes to a few kilobytes).\n\n\n\n - **Zoned-Bit Recording**: High-capacity disk technology where outer tracks (which have larger circumferences) are partitioned into more sectors than inner tracks. Tracks are grouped into approximately 10 zones.\n - **Disk Performance Metrics**:\n - **Seek Time**: Time required to move the read/write head arm to the target track.\n - **Latency (Rotation Delay)**: Average time required for the target sector to rotate underneath the read/write head (half the rotation period).\n - **Access Time**: Total time spent prior to data transfer: \text{Access Time} = \text{Seek Time} + \text{Latency}.\n - **Transfer Rate**: Rate at which data is transferred to or from the disk surface.\n - **Head Crash**: Operational failure where the read/write head contacts the spinning platter surface due to dust particles or mechanical shock, permanently destroying data and hardware. HDDs are factory sealed.\n - **Legacy Magnetic Media**: Magnetic Tape (high capacity, sequential linear access with long seek times) and Floppy Disks (removable single platter cartridges, low storage density).\n\n- **Optical Systems**:\n - **Compact Disk (CD)**: 12\,cm diameter reflective disk. Read using a laser reflecting off microscopic surface variations.\n - **Format**: Features a single continuous track spiraling outward from the inner hub to the outer edge, divided into sectors holding 2\,KB\frac{1}{75} second of stereo audio).\n\n\n\n - **Rotation Speed**: Audio CD-DA players adjust rotation speed (constant linear velocity) to maintain uniform data throughput. Computer CD drives run at higher, constant rotational speeds.\n - **Capacities**:\n - Standard CD: 600\,MB700\,MB\n - DVD (Digital Versatile Disk): Uses multiple semi-transparent layers and tighter laser focus to achieve several gigabytes capacity.\n - BD (Blu-ray Disk): Employs a blue-violet laser with shorter wavelength for finer focal precision, providing over 5\times the capacity of a DVD.\n\n- **Flash Memory and Solid-State Storage**:\n - **Flash Memory Technology**: Stores bits by trapping electrons in silicon dioxide micro-chambers via electrical signals. Non-volatile without external power supply.\n - **Operational Limits**: Data must be erased in large blocks rather than individual bytes. Repeated write/erase cycles degrade silicon dioxide chambers over time.\n - **Flash Drives**: Portable, cap-protected USB units providing hundreds of gigabytes of non-volatile storage.\n - **Solid-State Disks (SSD)**: Mass storage units built from flash memory designed as direct drop-in replacements for HDDs. Advantages include shock resistance, silent operation, zero seek/latency delay, and fast access times. Employ **wear-leveling** algorithms to dynamically reallocate write operations across cells.\n - **SD Cards (Secure Digital)**: Compact flash memory cards used in smartphones, digital cameras, and mobile hardware.\n - Standard SD: Up to 2\,GB\n - SDHC (High Capacity): Up to 32\,GB\n - SDXC (Extended Capacity): Exceeds 1\,TB\n\n# Representing Information as Bit Patterns\n\n- **Representing Text**:\n - Text is represented by assigning each character or symbol a unique bit pattern.\n - **ASCII (American Standard Code for Information Interchange)**:\n - Established by ANSI. Uses 709, punctuation, and control characters (line feed, carriage return, tab).\n - Standard ASCII is padded with a leading 081\,byte128128 extended patterns.\n - **ISO Standards**: Extended 8-bit ASCII variants tailored for regional language groups (e.g., adding symbols for European vowels ä, ö, ü, and currency like the British pound £).\n - **Unicode and UTF-8**:\n - Developed to support global multilingual text formatting within a single standard.\n - Unicode assigns unique codes using up to 21\,bits.\n - **UTF-8**: Variable-length encoding standard. Uses 8\,bits16\,bits24\,bits32\,bits for rare/specialized symbols.\n - **Text Files vs. Word Processing Files**:\n - **Text File**: Plain sequence of character-by-character ASCII or UTF-8 encodings edited by utility text editors.\n - **Word Processor File**: Complex format containing textual ASCII/Unicode strings interspersed with proprietary metadata for font styles, paragraph layout, alignment, and formatting.\n\n- **Representing Numeric Values**:\n - ASCII string encoding of numbers is inefficient (e.g., storing 252\,bytes16\,bits99).\n - Pure binary integer representation allows a 16065,535.\n - Numeric values are stored using specialized binary encodings: Two's Complement for signed integers and Floating-Point notation for fractional real numbers.\n\n- **Representing Images**:\n - **Bitmap (Raster) Graphics**: Images constructed as a two-dimensional grid of pixels (picture elements).\n - Black-and-white: 1\,bit01 = white).\n - Grayscale: Typically 1\,byte8\,bits256 shade levels).\n - RGB Encoding: Uses 3\,bytes1\,byte1\,byte1\,byte for Blue intensity).\n - Luminance/Chrominance Encoding: Encodes a pixel using Luminance (YC_bC_r).\n - **Vector (Geometric) Graphics**: Describes images as collections of geometric primitives (lines, curves, polygons) using analytic geometry.\n - Scalable to any dimension without loss of clarity or pixelation.\n - Standards: TrueType (fonts), PostScript (document rendering), and CAD systems.\n\n- **Representing Sound**:\n - **Sampling Method**: Measures wave amplitude at uniform time intervals.\n - Long-distance telephony: Sample rate of 8000\,samples/second.\n - Audio CD quality: Sample rate of 44,100\,samples/second16\,bits32\,bits1\,Mbit per second of audio.\n - **MIDI (Musical Instrument Digital Interface)**:\n - Stores synthesizer commands (note pitch, start time, duration, instrument code, volume) rather than recording the acoustic signal.\n - Extremely compact (e.g., a 23\,bytes2,000,000\,bits via PCM sampling).\n\n# The Binary System\n\n- **Binary Positional Notation**:\n - Base 1010^0 = 110^1 = 1010^2 = 100).\n - Base 22^0 = 12^1 = 22^2 = 42^3 = 82^4 = 162^5 = 32).\n - Decoding binary string 100101_2:\n 1 \times 32 + 0 \times 16 + 0 \times 8 + 1 \times 4 + 0 \times 2 + 1 \times 1 = 37\n\n- **Algorithm for Converting Base 10 Integer to Binary**:\n 1. Divide the integer by 2 and record the remainder.\n 2. Continue dividing the resulting quotient by 20$.
Read the remainders from bottom to top (last recorded remainder is the MSB).
Example (Converting to Binary):
remainder
remainder
remainder
remainder
Binary output: .
Binary Addition:
Elementary binary addition rules:
( write-down, carry )
( write-down, carry )
Binary Fractional Representations:
Uses a radix point (binary decimal point).
Fractional column positional values proceed as negative powers of two: , , ,
Example: Decoding : (or )
Storing Integers
Two's Complement Notation:
Fixed bit-length encoding standard for signed integer arithmetic.
Sign Bit: The most significant (leftmost) bit indicates sign ( for non-negative, for negative).
Encoding Non-negative Values: Formatted as plain binary numbers starting with 0$.\n - **Encoding Negative Values (Copy-and-Complement Algorithm)**:\n 1. Write the non-negative binary equivalent for the target magnitude.\n 2. Scan bits right-to-left, copying bits unchanged up to and including the first 1$.
Invert (complement) all remaining bits to the left (, ).
Example for in ‐bit system: Positive is
0110. Copying right-to-left yields0then1. Inverting remaining bits yields1010.
Two's Complement Range Limits:
For an ‐bit system, valid representable values range from to 2^{n-1} - 1$.\n - 3-43\n - 4-87\n - 16-32,76832,767\n - 32-2,147,483,6482,147,483,647\n\n- **Addition and Subtraction in Two's Complement**:\n - Addition is performed using standard binary bit addition. Any carry bit extending beyond the fixed bit length on the left is truncated.\n - Subtraction A - BB-BA + (-B).\n\n- **The Problem of Overflow**:\n - Occurs when a arithmetic operation produces a result outside the representable range of the fixed bit pattern.\n - Detected when adding two positive numbers yields a negative sign bit (10).\n\n- **Excess Notation**:\n - Fixed bit-length system where bit patterns are listed sequentially in binary order, with the midpoint pattern (starting with a leading 1) assigned to represent zero.\n - An n2^{n-1}.\n - 407-8).\n - 50).\n - 30).\n\n# Storing Fractions\n\n- **Floating-Point Notation Structure**:\n - Encodes real numbers using sign, exponent, and mantissa fields.\n - **8-bit Model Example Layout**:\n - Bit 701 for negative.\n - Bits 643\,bits stored in Excess 4 notation.\n - Bits 304\,bits storing significant binary fractional digits.\n\n- **Decoding Floating-Point Bit Patterns**:\n 1. Extract mantissa field and place a radix point on its left (`.mantissa`).\n 2. Extract exponent field and decode from Excess 4 notation to get exponent value e\n 3. Move the radix point ee > 0e < 0).\n 4. Apply the sign bit.\n - **Example (Decoding `01101011`)**:\n - Sign bit: 0 (positive).\n - Exponent `110`: Excess 4 representation of +2$.
Mantissa
.1011shifted places right yields .
Normalized Form:
Floating-point encodings require the mantissa field to be shifted so that its leading bit is always .
Eliminates redundant representations for identical values. Value zero is represented as a bit string of all s.
Truncation and Round-Off Errors:
Occur when the mantissa field lacks sufficient bit capacity to store low-order bits (e.g., attempting to encode [
10.101_2] into a ‐bit mantissa drops the trailing bit, truncating value to ).Base fractions like () produce infinitely repeating non-terminating binary fractions, causing unavoidable truncation errors in floating-point representations.
Non-associative arithmetic: Adding a very small floating-point number to a very large number can result in the small number being completely truncated. Small numbers should be summed together first.
Standard IEEE Formats:
Single Precision Floating Point: total ( sign, exponent, mantissa). Precision of approximately decimal digits.
Double Precision Floating Point: total ( sign, exponent, mantissa). Precision of approximately decimal digits.
Questions & Discussion
Questions & Exercises Review:
Question: What input bit patterns cause a circuit with an XOR gate feeding an AND gate to produce an output of ?
Answer: The output of the AND gate is only when both its inputs are . Therefore, the lower direct input must be , and the XOR gate output must be . The XOR gate produces when its two inputs differ. Thus, valid input patterns are
101and011(where top two inputs differ and the bottom input is ).Question: If a memory cell address contains value , what is the difference between writing into cell versus moving contents of cell to cell ?
Answer: Writing into cell stores the literal value at address . Moving contents of cell into cell copies the stored value () from address into address 6$.\n\n - **Question**: Swap the contents of memory cells 23. What is wrong with:\n - Step 1: Move contents of cell 23$.
Step 2: Move contents of cell to cell 2$.\n - **Answer**: Step 1 overwrites cell 34) must be used:\n 1. Move contents of cell 24$.
Move contents of cell to cell 2$.\n 3. Move contents of cell 43$.
Question: How many total bits exist in a memory?
Answer: . Multiplying by yields .
Question: When recording on a multi-platter disk system, should we fill an entire disk surface before moving to another surface, or fill an entire cylinder before moving to another cylinder?
Answer: Fill an entire cylinder first. Moving between tracks on a single cylinder requires only switching read/write head electronics, avoiding physical seek arm motion delays.
Question: What ethical implications exist regarding software truncation errors?
Answer: Responsibility for software failure or structural damages resulting from numerical truncation involves hardware designers, software architects, programmers, and deployment managers. Considerations include whether software updates/patches were made available, applied, or if software was improperly altered or pirated.