What to practice
- Convert between binary and decimal integers and rank mixed binary/decimal lists.
- Calculate minimum bit widths needed to encode N items (smallest n with 2^n >= N) and capacity multipliers 2^k.
- Distinguish integer overflow errors from floating-point roundoff errors.
1. Core Concept Instruction
All digital data (numbers, text characters via ASCII/Unicode, RGB pixels, audio samples, and machine instructions) are stored as sequences of bits (0s and 1s); the same bit sequence can represent an integer, a character, or a color depending on context (abstraction). In base-2 (binary), place values from right to left are powers of 2: 2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 2^5=32, 2^6=64, 2^7=128. With n bits, a system can uniquely represent 2^n distinct items (and unsigned integers from 0 to 2^n - 1). Adding 1 extra bit multiplies the number of representable patterns by 2 (and adding k bits multiplies capacity by 2^k). An Overflow Error occurs when an integer exceeds the maximum representable value (e.g., > 255 in an 8-bit unsigned byte), whereas a Roundoff Error occurs when a real number (like 1/3 or 0.1 in binary floating point) cannot be represented with exact finite precision.
2. Worked Examples
Worked Binary-Decimal Ranking, Bit-Capacity Scaling & Overflow vs. Roundoff
(a) Convert binary 110101_2 and 101110_2 to decimal and rank {110101_2, 101110_2, 50_{10}} from least to greatest. (b) A school uses 7-bit student IDs and expands to 10-bit IDs. How many times as many unique IDs can be represented?
Result:
Hexadecimal-to-Binary Nibble Conversion & Fixed-Width Roundoff vs. Overflow
Convert the two-digit hexadecimal color-channel value 0xB4 (one byte) into 8-bit binary and decimal, and classify what occurs when a 32-bit floating-point sensor stores 1/3.
Result: 0xB4 = 10110100_2 (decimal 180); storing 1/3 in floating-point produces a roundoff error
Core Concept Review
All digital data (numbers, text characters via ASCII/Unicode, RGB pixels, audio samples, and machine instructions) are stored as sequences of bits (0s and 1s); the same bit sequence can represent an integer, a character, or a color depending on context (abstraction). In base-2 (binary), place values from right to left are powers of 2: 2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 2^5=32, 2^6=64, 2^7=128. With n bits, a system can uniquely represent 2^n distinct items (and unsigned integers from 0 to 2^n - 1). Adding 1 extra bit multiplies the number of representable patterns by 2 (and adding k bits multiplies capacity by 2^k). An Overflow Error occurs when an integer exceeds the maximum representable value (e.g., > 255 in an 8-bit unsigned byte), whereas a Roundoff Error occurs when a real number (like 1/3 or 0.1 in binary floating point) cannot be represented with exact finite precision.
Extended Concept Analysis
All digital data (numbers, text characters via ASCII/Unicode, RGB pixels, audio samples, and machine instructions) are stored as sequences of bits (0s and 1s); the same bit sequence can represent an integer, a character, or a color depending on context (abstraction). In base-2 (binary), place values from right to left are powers of 2: 2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 2^5=32, 2^6=64, 2^7=128. With n bits, a system can uniquely represent 2^n distinct items (and unsigned integers from 0 to 2^n - 1). Adding 1 extra bit multiplies the number of representable patterns by 2 (and adding k bits multiplies capacity by 2^k). An Overflow Error occurs when an integer exceeds the maximum representable value (e.g., > 255 in an 8-bit unsigned byte), whereas a Roundoff Error occurs when a real number (like 1/3 or 0.1 in binary floating point) cannot be represented with exact finite precision.
Worked Problem Walkthrough
Worked Binary-Decimal Ranking, Bit-Capacity Scaling & Overflow vs. Roundoff
(a) Convert binary 110101_2 and 101110_2 to decimal and rank {110101_2, 101110_2, 50_{10}} from least to greatest. (b) A school uses 7-bit student IDs and expands to 10-bit IDs. How many times as many unique IDs can be represented?
Hexadecimal-to-Binary Nibble Conversion & Fixed-Width Roundoff vs. Overflow
Convert the two-byte hexadecimal color channel value 0xB4 into 8-bit binary and decimal, and classify what occurs when a 32-bit floating-point sensor stores 1/3.
Common Exam Traps & How to Avoid Them
-
Thinking that adding 3 bits increases capacity by 3 or 6 instead of multiplying capacity by 2^3 = 8.
-
Confusing overflow error (number too large for bit width) with roundoff error (repeating/inexact fractional binary representation like 0.1).
Key Vocabulary
-
Overflow Error: An error that occurs when a calculation produces an integer outside the range representable by the allocated number of bits.
-
Roundoff Error: Imprecision that occurs because fixed-bit floating-point representations can only approximate certain real numbers (such as 1/10 or 1/3).