IB Computer Science: How Binary is Used to Store Data

Physical Foundations of Binary Data Storage

  • Physical Transistors and Logic Gates:

    • Microscopic silicon gates inside computer chips function as physical on/off switches.

    • High Voltage State is represented as 11.

    • Low Voltage State is represented as 00.

    • This fundamental physical reality dictates the architectural requirement and mandatory use of the base-2 binary system.

  • Fundamental Storage Units:

    • Bit: A single bit represents a single binary digit (00 or 11).

    • Byte: By universal computer science convention, individual bits are grouped into 8-bit8\text{-bit} sequences known as Bytes.

    • Capacity of a Byte: A single Byte can represent 282^8 (256256) unique discrete values, ranging sequentially from 0000000000000000 to 1111111111111111.

  • Scale of Data Storage:

    • Secondary Storage Media: Data is read from and written to storage media in massive, sequential blocks of Bytes.

    • Persistence: Secondary storage devices—including Solid-State Drives (SSDs), flash drives, and Hard Disk Drives (HDDs)—persistently preserve millions of electrical or magnetic states even when powered down.

Character Encoding Standards

  • ASCII Standard (American Standard Code for Information Interchange):

    • Historical Context: Developed during the 1960s to establish a unified standard for digital text transmission.

    • 7-Bit7\text{-Bit} Encoding Architecture: ASCII maps exactly 128128 unique characters, corresponding to decimal values 00 through 127127.

    • Character Set Range: Encompasses uppercase English letters, lowercase English letters, numeric digits, and non-printable control characters.

    • Extended ASCII Variant: Utilizes an 8-bit8\text{-bit} (1 Byte1\,\text{Byte}) architecture to expand total character capacity to 256256 distinct characters, incorporating accent marks and extra characters.

    • Major Structural Limitation: Extended ASCII remains fundamentally incapable of encoding non-English foreign languages, specialized mathematical symbols, or modern emojis.

  • Unicode Standard:

    • Global Integration Goal: Engineered to represent every written character, symbol, and writing script across all human languages within a single, unified character set.

    • Variable-Width Encoding: Utilizes bit allocations of 8 bits8\,\text{bits}, 16 bits16\,\text{bits}, or 32 bits32\,\text{bits}. UTF-8 represents the most widely implemented encoding variant, assigning byte lengths dynamically based on character requirements.

    • Backward Compatibility: The initial 128128 code points of Unicode are mapped identically to standard ASCII, ensuring that legacy text files open accurately without character corruption.

    • Enormous System Scale: Accommodates over 1.1 million1.1\text{ million} distinct code points, easily supporting complex character sets like Chinese scripts as well as modern emojis.

Bitmap Graphics and Pixel Encoding

  • Mechanics of Bitmap Graphic Encoding:

    • Grid Abstraction: Visual images are divided into a dense grid of microscopic, discrete elements termed pixels (short for picture elements).

    • Pixel Coordinates and Binary Representation: In a basic monochrome (black-and-white) image grid, a single bit encodes each individual pixel:

    • 0=white0 = \text{white}

    • 1=colored1 = \text{colored}

    • Color Bit Depth: To encode color graphics, multiple bits are assigned to every single pixel:

    • 1-Bit Depth1\text{-Bit Depth}: Provides 21=22^1 = 2 colors (Monochrome).

    • 8-Bit Depth8\text{-Bit Depth}: Provides 28=2562^8 = 256 distinct colors.

    • 24-Bit Depth24\text{-Bit Depth} (True Color): Provides 224=16.7 Million2^{24} = 16.7\text{ Million} distinct colors, utilizing 8 bits8\,\text{bits} dedicated to Red, 8 bits8\,\text{bits} dedicated to Green, and 8 bits8\,\text{bits} dedicated to Blue.

  • Exemplar 8x8 Pixel Grid Data (Smiley Face Binary Matrix):

    • Row 1: 0 0 1 1 1 1 0 0

    • Row 2: 0 1 0 0 0 0 1 0

    • Row 3: 1 0 1 0 0 1 0 1

    • Row 4: 1 0 0 0 0 0 0 1

    • Row 5: 1 0 1 0 0 1 0 1

    • Row 6: 1 0 0 1 1 0 0 1

    • Row 7: 0 1 0 0 0 0 1 0

    • Row 8: 0 0 1 1 1 1 0 0

Analog Sound Digitization Process

  • Capture and Convert (Analog-to-Digital Converter - ADC):

    • Physical sound waves exist in nature as continuous, smooth analog signals.

    • An audio input hardware device, such as a microphone, captures physical audio vibrations.

    • An Analog-to-Digital Converter (ADC) converts this continuous analog signal into discrete numeric values suitable for processing by a Central Processing Unit (CPU).

  • Sample and Quantize (Sampling Rate and Bit Resolution):

    • The ADC takes periodic amplitude snapshots at a specified Sampling Rate, measured in Hertz (Hz\text{Hz}).

    • Compact Disc (CD) Quality Standard: Uses a sampling rate of 44.1 kHz44.1\,\text{kHz} (44,10044,100 samples per second).

    • Bit Depth (Resolution): Refers to the binary bits allocated per sample measurement. Higher bit depth allows for a significantly more accurate measurement of amplitude.

  • Decode and Output (Digital-to-Analog Converter - DAC):

    • To play sound back, the computer reads stored binary numbers sequentially from secondary storage.

    • A Digital-to-Analog Converter (DAC) translates each sequential binary number into an electrical voltage state.

    • This process reconstructs a smooth waveform sent to speakers to generate physical sound.

File Size Formulas and Exemplar Calculations

  • Standard Formulas for Data File Calculations:

    • Text Document File Size Formula:     Size=Characters×Bits per Character\text{Size} = \text{Characters} \times \text{Bits per Character}

    • Bitmap Image File Size Formula:     Size=Width×Height×Color Bit Depth\text{Size} = \text{Width} \times \text{Height} \times \text{Color Bit Depth}

    • Digital Audio File Size Formula:     Size=Sample Rate×Bit Depth×Channels×Seconds\text{Size} = \text{Sample Rate} \times \text{Bit Depth} \times \text{Channels} \times \text{Seconds}

  • Text Document Calculation Example:

    • Scenario: A text document contains 1,5001,500 characters stored using standard 8-bit8\text{-bit} ASCII (1 Byte1\,\text{Byte} per character).

    • Calculation in Bits:     1,500×8 bits=12,000 bits1,500 \times 8\,\text{bits} = 12,000\,\text{bits}

    • Calculation in Bytes:     12,0008=1,500 Bytes\frac{12,000}{8} = 1,500\,\text{Bytes}

    • Total Estimated File Size: Approximately 1.5 KB1.5\,\text{KB}.

  • Bitmap Image Calculation Example:

    • Scenario: A digital uncompressed photo has spatial dimensions of 800×600800 \times 600 pixels with 24-bit24\text{-bit} True Color.

    • Calculation in Bits:     800×600×24 bits=11,520,000 bits800 \times 600 \times 24\,\text{bits} = 11,520,000\,\text{bits}

    • Calculation in Bytes:     11,520,0008=1,440,000 Bytes\frac{11,520,000}{8} = 1,440,000\,\text{Bytes}

    • Total Estimated File Size: Approximately 1.44 MB1.44\,\text{MB}.

  • Digital Audio Calculation Example:

    • Scenario: A 10-second10\text{-second} CD-quality audio file with a sampling rate of 44.1 kHz44.1\,\text{kHz}, 16-bit16\text{-bit} depth, and Stereo audio (Stereo=2 channels\text{Stereo} = 2\,\text{channels}, Mono=1 channel\text{Mono} = 1\,\text{channel}).

    • Calculation in Bits:     44,100×16 bits×2 channels×10 s=14,112,000 bits44,100 \times 16\,\text{bits} \times 2\,\text{channels} \times 10\,\text{s} = 14,112,000\,\text{bits}

    • Calculation in Bytes:     14,112,0008=1,764,000 Bytes\frac{14,112,000}{8} = 1,764,000\,\text{Bytes}

    • Total Estimated File Size: Approximately 1.76 MB1.76\,\text{MB}.

Questions & Discussion

  • Question 1: Distinguishing Stored Data Types (2 Marks):

    • Prompt: Describe how a computer distinguishes between an integer and a character when both are stored as the exact same binary sequence (e.g., 01000001) in memory.

    • Explanation: Memory cells are context-blind. The CPU depends entirely on the current execution context and the instructions of the running compiler or interpreter program to decide how to parse and interpret the data.

  • Question 2: ASCII vs. Unicode Comparison (4 Marks):

    • Prompt: Compare ASCII and Unicode character sets, stating one advantage and one disadvantage of transitioning a global application to Unicode.

    • Advantage: Unicode maps characters from all world languages into a single set, avoiding translation and rendering errors across international boundaries.

    • Disadvantage: Unicode uses more storage space per character (variable length up to 32 bits32\,\text{bits} per character compared to ASCII's fixed 77 or 88 bits), which increases memory footprint and bandwidth requirements.

  • Question 3: Audio Digitization Steps (3 Marks):

    • Prompt: Explain how a continuous analog sound wave is converted into a binary format suitable for storage on secondary devices.

    • Explanation: The process requires three consecutive steps:

    1. Sound wave capture: A microphone captures continuous physical sound waves.

    2. Rapid sampling: An Analog-to-Digital Converter (ADC) takes rapid measurements at regular timed intervals ( sampling rate measured in Hz).

    3. Quantization mapping: Measured amplitude levels are mapped (quantized) into discrete numeric values and assigned corresponding binary code sequences based on the set bit depth resolution.