Computer Science · Cheatsheet
Topic 2 · Computer Organisation
Chapter 4 · Going deeper & exam practice
📋 Reference · always available
Binary addition
Bit rules: 0+0=0, 0+1=1, 1+1=10 (write 0 carry 1), 1+1+1=11 (write 1 carry 1).
Subtraction = addition
Subtract X by adding the two's-complement negation of X. One adder circuit does both.
Overflow
Result outside the representable range. In n-bit two's complement: max +2^(n-1)−1, min −2^(n-1). Overflow gives a SILENTLY wrong result.
Hex ↔ binary
Each hex digit = exactly 4 bits. Convert digit-by-digit. Hex is binary in compact form.
De Morgan's Laws
NOT(A AND B) = (NOT A) OR (NOT B). NOT(A OR B) = (NOT A) AND (NOT B).
Absorption Law
X OR (X AND Y) = X. X AND (X OR Y) = X. Used to simplify expressions and reduce gate count.
XOR
Exclusive OR: true when inputs DIFFER. Standard form: (A AND NOT B) OR (NOT A AND B).
Floating-point trap
0.1 + 0.2 ≠ 0.3 exactly. Most decimal fractions cannot be represented in binary precisely → rounding errors.
Bit width matters
Always pick a type wide enough for your value range. 16-bit signed → ±32767. Ariane 5: $370M lost to one overflow.
Cache-friendly code
Iterate data in MEMORY ORDER (row-major in C/Python). Same algorithm, 10× speed difference is realistic.