All revision notes

Computer Studies Revision Notes

Number Systems & Data Representation: Binary, Octal, Hexadecimal & Character Codes

Master step-by-step conversions across Binary (Base 2), Octal (Base 8), Denary (Base 10), and Hexadecimal (Base 16), binary arithmetic, two’s complement negative numbers, and ASCII/Unicode.

1. Why Computers Use Binary & Positional Number Bases

Digital electronic circuits rely on millions of microscopic transistor switches that exist reliably in two voltage states: OFF (0) and ON (1). Because long binary strings are tedious for humans, programmers group binary bits into Octal (Base 8: 3 bits per digit) and Hexadecimal (Base 16: 4 bits per digit). - Hexadecimal Digits (0–15): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15). - Where Hexadecimal Is Used: HTML/CSS web colour codes (#1657E2), MAC network addresses, IPv6 addresses, and CPU memory dumps.

2. Worked Conversions: Denary, Binary, Octal & Hexadecimal

- Example 1 — Denary to Binary (Repeated Division by 2): Convert 45_{10} to base 2. - 45 ÷ 2 = 22 R 1 - 22 ÷ 2 = 11 R 0 - 11 ÷ 2 = 5 R 1 - 5 ÷ 2 = 2 R 1 - 2 ÷ 2 = 1 R 0 - 1 ÷ 2 = 0 R 1 Reading remainders bottom-to-top: 45_{10} = 101101_2. - Example 2 — Binary to Hexadecimal (4-Bit Grouping): Convert 11010110_2 to base 16. Split into nibbles from right to left: (1101)_2 and (0110)_2. - 1101_2 = 8 + 4 + 0 + 1 = 13 = D_{16} - 0110_2 = 0 + 4 + 2 + 0 = 6_{16} Hence 11010110_2 = D6_{16}. - Example 3 — Hexadecimal to Denary: Convert 2F_{16} to base 10. 2F_{16} = (2 × 16^1) + (15 × 16^0) = 32 + 15 = 47_{10}

3. Binary Arithmetic & Two’s Complement Representation

Binary addition follows four simple rules: 0+0=0, 0+1=1, 1+1=10_2 (write 0, carry 1), and 1+1+1=11_2 (write 1, carry 1). - Worked Binary Addition: Add 1011_2 + 1101_2. - Column 2^0: 1+1 = 10_2 (write 0, carry 1) - Column 2^1: 1+0+1 = 10_2 (write 0, carry 1) - Column 2^2: 0+1+1 = 10_2 (write 0, carry 1) - Column 2^3: 1+1+1 = 11_2 (write 11) Result: 11000_2 (Check: 11 + 13 = 24, and 16 + 8 = 24 ✓). - Signed Integers via Two’s Complement (8-Bit): To represent -18_{10} in 8-bit two’s complement: 1. Write +18 in 8 bits: 00010010_2. 2. Flip all bits (One’s complement): 11101101_2. 3. Add 1: 11101101_2 + 1 = 11101110_2. The leftmost bit (MSB = 1) confirms the number is negative.

4. Character Encoding (BCD, ASCII, EBCDIC & Unicode) & Examiner Traps

- BCD (Binary Coded Decimal): Encodes each decimal digit 0–9 independently in 4 bits (e.g., 25_{10} = 0010\;0101_{BCD}—used in digital clocks and calculators). - ASCII (American Standard Code for Information Interchange): Standard ASCII uses 7 bits (2^7 = 128 characters: 'A' = 65, 'a' = 97, '0' = 48); Extended ASCII uses 8 bits (256 characters). - EBCDIC: 8-bit encoding developed for IBM mainframes. - Unicode (UTF-8 / UTF-16): Uses 16–32 bits to encode over 140,000+ characters, supporting Yoruba/Igbo/Hausa tonal marks, Arabic, Chinese, math symbols, and emojis globally. Examiner Trap: Never read division remainders top-to-bottom when converting denary to binary—the first remainder is the Least Significant Bit (rightmost), and the last remainder is the Most Significant Bit (leftmost). Also remember 'A' in ASCII is 65, while lowercase 'a' is 97 (a difference of +32).