Number systems, codes and Boolean algebra
Scope of the domain
This domain tests fluent conversion between decimal, binary, octal and hexadecimal, signed-number representations, weighted and non-weighted codes, and manipulation of Boolean expressions. Questions are usually short but unforgiving: one lost carry or a misapplied De Morgan bar changes the answer.
Core rules
- Positional weights: binary weights are powers of two from the radix point; group four bits for hex and three bits for octal, starting at the point.
- An n-bit two's-complement word represents -2^(n-1) to +2^(n-1)-1. Negation is invert-all-bits then add 1.
- Sign-magnitude and one's complement each have two zeros; two's complement has one zero and one extra negative value.
- BCD encodes each decimal digit in four bits; codes 1010-1111 are invalid, and addition needs a +6 correction when a nibble exceeds 9 or a carry occurs.
- Gray code changes one bit between adjacent words; it is used for encoders and asynchronous crossings.
- Boolean identities: X+0=X, X·1=X, X+X'=1, X·X'=0, absorption X+XY=X, consensus XY+X'Z+YZ=XY+X'Z.
- De Morgan: (X+Y)' = X'Y' and (XY)' = X'+Y'. Break the bar and change the operator.
Worked example
Express -45 as an 8-bit two's-complement byte. +45 = 32+8+4+2 = 0010 1101. Invert: 1101 0010. Add 1: 1101 0011 = D3h. Check: D3h = 211 unsigned, and 211-256 = -45, so the result is valid in the -128..+127 range. A 4-bit answer would be impossible because -45 lies outside -8..+7. For a fractional conversion, multiply the fraction repeatedly by 2 and read the carries downward: 0.375 × 2 = 0.75 carry 0, 0.75 × 2 = 1.5 carry 1, 0.5 × 2 = 1.0 carry 1, giving 0.011.
Traps that cost marks
Forgetting the final +1 when negating; padding with the wrong sign bit; writing invalid BCD codes after addition; dropping parentheses when applying De Morgan; and confusing minterm index (binary value of the input combination) with maxterm index (its complement).