Comprehensive Notes on Binary Representation, Boolean Logic, and Computer Architecture

Character Encoding and Text Representation

  • General Concept of Binary Representation: Everything in a computer—including video games, music, and images—must be represented at the most base level as ones and zeros. This process of representing worldly experience in binary is known as binary representation.

  • Inventory of Characters: To represent text, the computer must map characters to numbers. Characters include:     - Lowercase letters: 26 characters.     - Uppercase letters: 26 characters.     - Space bar: At least one character.     - Punctuation: Comma, decimal, periods, semicolons, colons, parentheses, brackets, etc.     - Numbers: Even though they are numbers, when printed on a screen, they are symbols (characters) rather than mathematical values stored in the computer's "brain."

  • Determining Bit Count: The number of things that can be stored is determined by the formula 2n2^n, where nn is the number of bits.     - 1 bit = 212^1 = 2 things (00 and 11).     - 2 bits = 222^2 = 4 things (0000, 1010, 0101, 1111).     - 3 bits = 232^3 = 8 things (00 to 77).

  • ASCII (American Standard Code for Information Interchange):     - Developed in the 1950s and 60s.     - Uses 7 bits to represent 128 characters (00 to 127127).     - Maps English characters and punctuation to numbers. Examples:         - Space = 3232         - Number "1" = 4949         - Number "2" = 5050         - Capital Letters = Start at 6565         - Lowercase Letters = Start at 9797     - Special Control Characters: The first ~30 characters include things like the "Bell" (which used to ring a physical bell, now a beep) and typewriter-based commands.

  • Typewriter Influence (Carriage Return and Line Feed):     - Modern computer "Enter" keys often still use the arrow symbol representing typewriter mechanics.     - Carriage Return: Moving the carriage back to the start of the line.     - Line Feed: Moving the paper down to the next line.     - In code, the "Enter" action is actually two distinct symbols: carriage return and line feed.

  • Extended ASCII: By adding just one bit to make it an 8-bit system (28=2562^8 = 256 characters), the chart doubled in size. This allowed for international symbols (Yen marker, Pound), Greek letters for math, and "box-drawing" characters used to create windows in text-based interfaces.

  • Unicode:     - Provides a much larger room for characters (currently almost 300,000 characters, with room to grow).     - Includes emojis, which are managed by a consortium from Japan.     - Emoji Application Process: Anyone can apply for a new emoji. Subcommittees review applications and then a larger committee votes. They approve the name and description, but individual companies (Apple, Google, etc.) design their own visual versions.     - Example: A group of adults voted multiple times to approve the "smiling pile of poo" as a required part of text-based communication.

Representing Negative Numbers and Two's Complement

  • Overflow Definition: Overflow occurs when a mathematical result exceeds the physical number of columns (bits) available in a system. In computers, the extra digit is simply "thrown away."

  • Hundreds Complement (Decimal Analogy):     - In a hypothetical 2-digit decimal system (0000 to 9999), adding something to 7272 that results in 0000 (due to overflow) identifies the negative version of that number.     - If 72+28=10072 + 28 = 100, and we throw away the 11 (the overflow), the result is 0000. Therefore, in this system, 2828 acts as 72-72.

  • One's Complement: To find the negative of a binary number like 5 (0000010100000101), you "flip the bits" or invert them, turning every 00 to a 11 and every 11 to a 00.

  • Two's Complement (Standard System): This is the primary way computers represent negative numbers because it allows the hardware to add and subtract using the same addition circuitry.     - Step 1: Write the positive version of the number in binary.     - Step 2: Flip the bits (One's Complement).     - Step 3: Add 11 to the result.     - Adding a negative number in two's complement to its positive counterpart will result in zero (plus an overflow bit that the computer ignores).

Real Numbers and Floating Point Notation

  • IEEE Floating Point Notation: Developed by the Institute of Electrical and Electronics Engineers (IEEE) to represent real (decimal/fractional) numbers. It is based on scientific notation: m×2em \times 2^e.

  • Components of a Float:     - Sign: One bit representing positive or negative.     - Mantissa: Also called the fractional part.     - Exponent: The power the base is raised to.

  • Precision and Limits:     - Float: 32-bit representation.     - Double: Twice as large (64-bit), offering more accuracy.     - Place Values in Binary Fractions:         - 21=122^{-1} = \frac{1}{2}         - 22=142^{-2} = \frac{1}{4}         - 23=182^{-3} = \frac{1}{8}         - 24=1162^{-4} = \frac{1}{16}

  • Floating Point Error: Computers cannot perfectly represent every possible real number. Because numbers are stored as a finite collection of fractions, some values are impossible to reach exactly. This creates local imperfections or "errors" that programmers must manage, especially in sensitive areas like banking (where money is usually stored as two whole numbers: dollars and cents).

Boolean Logic and Logic Gates

  • Boolean Algebra: Named after George Boole. It operates on bits (True/False, On/Off, 1/0). Computer circuits are built out of these logical relationships.

  • Logic Gates with Two Inputs (AND, OR):     - AND Gate: The output is only 11 when BOTH inputs are 11. (Example: "If you get an A in math AND an A in English, you get ice cream.")     - OR Gate: The output is 11 if EITHER input (or both) is 11. It is only 00 when both inputs are 00.

  • The NOT Gate: A single-input gate that "inverts" the value. If input is 00, output is 11. If input is 11, output is 00.

  • Derived Gates:     - NAND (Not AND): The opposite of an AND gate (11101110).     - NOR (Not OR): The opposite of an OR gate (10001000).     - XOR (Exclusive OR): The output is only true (11) if exactly one of the inputs is on. If both are off or both are on, the output is 00.

Practical Computer Architecture: Adders and Latches

  • The Adder: A circuit that adds binary numbers together using logic gates.     - Half Adder: Consists of an XOR gate (to find the sum ss) and an AND gate (to find the carry cc).     - Truth Table for Adder:         - 0+0=00 + 0 = 0 (Sum), 00 (Carry)         - 0+1=10 + 1 = 1 (Sum), 00 (Carry)         - 1+1=01 + 1 = 0 (Sum), 11 (Carry) [Resulting in binary 1010, which is 22]     - Full Adder: A series of connected adders (e.g., 64 of them for a 64-bit machine) that can process carries from previous columns.

  • Memory and Latches: Circuits used to store bits.     - SR Latch: Can be "Set" (made 11) or "Reset" (made 00).     - NAND Flash: Most common flash memory is built entirely out of millions of NAND gates.

  • Physical Nature of Computing: These are not mechanical; they are chemical and electrical processes. Transistors on silicon wafers allow electricity to flow through these circuits without moving parts.

  • ALU (Arithmetic Logic Unit): The part of the CPU where these mathematical and logical calculations occur.

  • FPGA (Field Programmable Gate Array): A specialized chip containing a sea of gates that remain undefined until a programmer writes code to configure them into a specific circuit.