Data Representation and Digital Logic
Data Representation and Digital Logic tests how values are encoded in bits and how Boolean circuits transform them. Questions often require converting bases, computing two’s-complement ranges, spotting overflow, or completing a truth table.
Integers and text
Unsigned n-bit integers range from 0 to 2^n−1. Two’s complement represents negatives by inverting bits and adding 1; an n-bit signed range is −2^(n−1) to 2^(n−1)−1. ASCII is a 7-bit character set; Unicode assigns code points and UTF-8 is a variable-length encoding. Binary addition follows the same column rules as decimal, with carry.
Floating point
Floating-point representations store sign, exponent, and fraction. They approximate real numbers, so 0.1 + 0.2 may not equal 0.3 exactly. Rounding and limited precision cause errors; never assume exact equality for floating-point results.
Boolean logic
AND outputs 1 only when both inputs are 1; OR outputs 1 when at least one input is 1; NOT inverts; XOR outputs 1 when inputs differ. Boolean algebra simplifies circuits: A·(A+B)=A, A+A′B=A+B, and De Morgan’s laws turn AND into OR with inversions.
Worked example
Represent −5 in 8-bit two’s complement. Write +5 as 00000101. Invert: 11111010. Add 1: 11111011. Check the sign bit is 1, and the value is −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5.
Traps
Do not treat the leftmost bit as a plain magnitude when signed. Overflow occurs when the result falls outside the representable range, not simply when a carry occurs. In truth tables, include every input combination. Distinguish character encoding from the glyph displayed.