AP Computer Science Principles: Digital Information and Binary Representation Study Guide

Binary Number System and Base Conversions

  • Converting Decimal Values to Binary:

    • Decimal 5555 Conversion:
    • To convert decimal 5555 to binary (base 22), evaluate the highest powers of 22 that sum to 5555:
      • 25=322^5 = 32
      • 5532=2355 - 32 = 23
      • 24=162^4 = 16
      • 2316=723 - 16 = 7
      • 23=82^3 = 8 (does not fit into 77, binary digit is 00
      • 22=42^2 = 4
      • 74=37 - 4 = 3
      • 21=22^1 = 2
      • 32=13 - 2 = 1
      • 20=12^0 = 1
      • 11=01 - 1 = 0
    • Combining these powers yields 32+16+0+4+2+1=5532 + 16 + 0 + 4 + 2 + 1 = 55, which corresponds to the binary sequence 110111.
    • Comparison of binary candidate options for decimal 5555:
      • 111011: Corresponds to 32+16+8+0+2+1=5932 + 16 + 8 + 0 + 2 + 1 = 59
      • 110111: Corresponds to 32+16+0+4+2+1=5532 + 16 + 0 + 4 + 2 + 1 = 55 (Correct representation)
      • 11011: Corresponds to 16+8+0+2+1=2716 + 8 + 0 + 2 + 1 = 27
      • 11111: Corresponds to 16+8+4+2+1=3116 + 8 + 4 + 2 + 1 = 31
    • Decimal 8989 Conversion:
    • To convert decimal 8989 to binary (base 22), decompose 8989 into powers of 22:
      • 26=642^6 = 64
      • 8964=2589 - 64 = 25
      • 25=322^5 = 32 (does not fit into 2525, binary digit is 00
      • 24=162^4 = 16
      • 2516=925 - 16 = 9
      • 23=82^3 = 8
      • 98=19 - 8 = 1
      • 22=42^2 = 4 (does not fit into 11, binary digit is 00
      • 21=22^1 = 2 (does not fit into 11, binary digit is 00
      • 20=12^0 = 1
      • 11=01 - 1 = 0
    • Combining these values yields 64+0+16+8+0+0+1=8964 + 0 + 16 + 8 + 0 + 0 + 1 = 89, which corresponds to the binary sequence 1011001.
    • Comparison of binary candidate options for decimal 8989:
      • 101101: Corresponds to 32+0+8+4+0+1=4532 + 0 + 8 + 4 + 0 + 1 = 45
      • 11001101: Corresponds to 128+64+0+0+8+4+0+1=205128 + 64 + 0 + 0 + 8 + 4 + 0 + 1 = 205
      • 0101101: Corresponds to 32+0+8+4+0+1=4532 + 0 + 8 + 4 + 0 + 1 = 45
      • 1011001: Corresponds to 64+0+16+8+0+0+1=8964 + 0 + 16 + 8 + 0 + 0 + 1 = 89 (Correct representation)
  • Ordering Numerical Values Across Different Bases:

    • To order a mixed list of binary and decimal numbers from least to greatest, convert all numbers to base 1010:
    • Binary 1100: 23+22+0+0=8+4=122^3 + 2^2 + 0 + 0 = 8 + 4 = 12
    • Binary 1001: 23+0+0+20=8+1=92^3 + 0 + 0 + 2^0 = 8 + 1 = 9
    • Decimal 6: 66
    • Decimal 8: 88
    • Numerical ordering from least to greatest:
    1. Decimal 6 (Value: 66
    2. Decimal 8 (Value: 88
    3. Binary 1001 (Value: 99
    4. Binary 1100 (Value: 1212
    • Correct ordered sequence: Decimal 6, Decimal 8, Binary 1001, Binary 1100.
  • Binary Sequences and Incremental Operations:

    • Incrementing Binary Sequences:
    • Binary sequences increase by 11 through binary addition, adding 11 to the least significant bit and carrying over as necessary.
    • Evaluation of 88-bit binary sequences increasing by 11 each step:
      • Sequence 0001 0110 (2222), 0001 0111 (2323), 0001 1000 (2424): Increases by 11 at each consecutive step (Correct).
      • Sequence 0001 0110 (2222), 0001 0111 (2323), 0001 1111 (3131): Discontinuous jump from 2323 to 3131
      • Sequence 1010 1010 (170170), 1010 1100 (172172), 1010 1101 (173173): Increments by 22 on the first step.
      • Sequence 1011 1110 (190190), 1011 1111 (191191), 1010 0000 (160160): Value decreases at the final step.
    • Identifying Missing Binary Values in Sequences:
    • Given a 55-bit binary list representing sequential decimal values from 1515 to 1818:
      • Decimal 1515: 01111 (8+4+2+1=158 + 4 + 2 + 1 = 15
      • Decimal 1616: 10000 (1616
      • Decimal 1717: 10001 (16+1=1716 + 1 = 17
      • Decimal 1818: 10010 (16+2=1816 + 2 = 18
    • The missing 55-bit binary value corresponding to decimal 1717 in the list between 10000 and 10010 is 10001.

Bit Depth, Capacity, and Data Representation

  • Fundamental Rules of Bit Capacity:

    • An nn-bit binary system can represent exactly 2n2^n unique combinations or states.
    • The range of non-negative integers representable in nn bits extends from 00 to 2n12^n - 1.
  • Scaling Bit Systems and System Upgrades:

    • Adding 11 Bit to a Binary System:
    • Upgrading a system from nn bits to n+1n + 1 bits multiplies the total number of unique representable items by 22.
    • Mathematical ratio: 2n+12n=21=2\frac{2^{n+1}}{2^n} = 2^1 = 2
    • Example: A school upgrading ID storage from a 55-bit system (25=322^5 = 32 total IDs) to a 66-bit system (26=642^6 = 64 total IDs) allows 22 times as many IDs to be added/stored overall.
    • Evaluating Fixed Bit Depth Margins:
    • A system storing multiple-choice test options using 44 bits per option can represent up to 24=162^4 = 16 unique options.
    • If a test expands the number of options per question from 44 options to 88 options, no increase in bits is required because 8168 \le 16. The fixed 44-bit length remains fully sufficient.
  • Determining Minimum Bit Depth Requirements:

    • Unique Staff ID Allocation:
    • Requirement: Assign unique ID numbers to 150150 staff members.
    • Calculation for required bits nn:
      • n=7n = 7 bits: 27=1282^7 = 128 unique IDs (128<150128 < 150, insufficient)
      • n=8n = 8 bits: 28=2562^8 = 256 unique IDs (256150256 \ge 150, sufficient)
    • Result: A minimum of 88 bits is required to provide each of the 150150 workers a unique binary ID.
    • Character Set Encoding:
    • Requirement: Assign unique binary codes to 100100 distinct text characters.
    • Calculation for required bits nn:
      • n=5n = 5 bits: 25=322^5 = 32 characters (32<10032 < 100, insufficient)
      • n=6n = 6 bits: 26=642^6 = 64 characters (64<10064 < 100, insufficient)
      • n=7n = 7 bits: 27=1282^7 = 128 characters (128100128 \ge 100, sufficient)
    • Result: A minimum of 77 bits is required to represent 100100 unique characters.
  • Network Protocol Address Scaling (IPv4 vs. IPv6):

    • Internet Protocol version 4 (IPv4) utilizes 3232-bit binary addresses, providing 2322^{32} unique addressable nodes.
    • Internet Protocol version 6 (IPv6) utilizes 128128-bit binary addresses, providing 21282^{128} unique addressable nodes.
    • Quantitative expansion factor when upgrading from IPv4 to IPv6:
    • 2128232=212832=296\frac{2^{128}}{2^{32}} = 2^{128 - 32} = 2^{96}
    • Upgrading from IPv4 to IPv6 yields 2962^{96} times as many available IP addresses.
  • Representation of Complex Media Types:

    • Binary sequences serve as the universal digital representation for all computer data.
    • Abstract media types representable by binary sequences include:
    • I. Sound (encoded by sampling analog audio waves at discrete intervals)
    • II. A String of Characters (encoded via fixed-length or variable-length bit patterns such as ASCII or Unicode)
    • III. Video (encoded as sequences of digital images and synchronized audio channels)
    • All three media types (I, II, and III) are represented using binary sequences.

Integer Representation Limits and Overflow Errors

  • Mechanism of Overflow Errors:

    • Computer systems allocate a fixed number of bits to store integers.
    • An overflow error occurs when an arithmetic operation computes a value that exceeds the maximum numerical threshold representable within the fixed bit limit allocated for that variable.
  • Quantitative Example of Arithmetic Overflow:

    • Environment: A programming language utilizes 33 bits to store non-negative integers.
    • Maximum representable value: 231=72^3 - 1 = 7
    • Attempted operation: A program attempts to add decimal values 33 and 66 and assign the result to variable num.
    • Step-by-step analysis:
    • Value 33 in binary: 011 (fits in 33 bits)
    • Value 66 in binary: 110 (fits in 33 bits)
    • Computed sum: 3+6=93 + 6 = 9
    • Value 99 in binary: 1001 (requires 44 bits)
    • Result: An overflow error occurs because the sum 99 cannot be represented using 33 bits (9>79 > 7).
  • Distinguishing Overflow Errors from Round-off Errors:

    • Overflow Error: Triggered when an integer calculation yields a magnitude greater than the maximum allowable value for a fixed bit width.
    • Round-off Error: Triggered when fractional or floating-point numbers cannot be stored with exact precision due to bit limits, leading to approximate representations.