Data Representation and Number System Conversions
What the examiner tests
Accuracy in converting between bases, signed representation, and units of data storage. Marks are lost through small slips, not lack of theory.
Core rules
- Decimal → other base (integer part): divide repeatedly by the target base, note the remainders, and read them bottom to top.
- Decimal → other base (fraction): multiply the fraction repeatedly by the base, take the integer part each time, read top to bottom.
- Binary ↔ octal: group bits in threes from the radix point; binary ↔ hex: group in fours. Pad with zeros at the ends.
- Signed numbers: in sign-magnitude the leftmost bit is the sign (0 = +, 1 = −). In 1’s complement, invert all bits of the magnitude; in 2’s complement, invert and add 1. For n bits, the 2’s complement range is −2^(n−1) to +2^(n−1) − 1.
- BCD stores each decimal digit in 4 bits (37 → 0011 0111). ASCII is a 7-bit code for 128 characters; Unicode covers the scripts of many languages.
- 1 byte = 8 bits, 1 KB = 1024 B, 1 MB = 1024 KB. Storage manufacturers often use 1000-based units, which is why a “500 GB” disk shows less.
Worked example
Represent −25 in 8-bit 2’s complement. 25 = 0001 1001. Invert: 1110 0110. Add 1: 1110 0111. Check: 1110 0111₂ = 231, and 231 + 25 = 256 = 2⁸, as required for an 8-bit negative number.
Traps
- Not padding to the full width before inverting.
- Reading remainders top-to-bottom instead of bottom-to-top.
- Taking the 2’s complement of a positive number - positives are unchanged.
- Confusing 1’s complement’s two zeros (00000000 and 11111111) with 2’s complement’s single zero.
- Reading BCD 0001 0010 as a binary pattern instead of decimal 12.