Sample Cheat Sheets: Number Systems
IGCSE / O Level Computer Science Cheat Sheet
Topic: 1.1 Number Systems
🔢 Number Systems Overview
System | Base | Digits Used | Example |
---|---|---|---|
Denary | 10 | 0–9 | 125 |
Binary | 2 | 0, 1 | 1011 |
Hexadecimal | 16 | 0–9, A–F | 7F |
🔁 Conversions
✅ Denary ↔ Binary
To Convert Denary to Binary:
- Repeatedly divide by 2, write remainders in reverse order.
Example: 13 → Binary
13 ÷ 2 = 6 R1
6 ÷ 2 = 3 R0
3 ÷ 2 = 1 R1
1 ÷ 2 = 0 R1
→ Binary = 1101
To Convert Binary to Denary:
- Multiply each bit by 2^position (from right), then add.
Example: 1101 → Denary
1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13
✅ Denary ↔ Hexadecimal
To Convert Denary to Hex:
- Repeatedly divide by 16 and use hex digits.
Example: 255 → Hex
255 ÷ 16 = 15 R15 → FF
To Convert Hex to Denary:
- Multiply each digit by 16^position (from right).
Example: 7F → Denary
7×16¹ + 15×16⁰ = 112 + 15 = 127
✅ Binary ↔ Hexadecimal
Group binary in 4s from right → convert to hex.
Example: 10111111 → Hex
1011 1111
→ B F → BF
Hex BF → Binary
B = 1011
, F = 1111
→ 10111111
🔠 Why Hex is Used
- Shorter than binary
- Easier for humans to read/debug
- Often used in color codes, memory addresses, MAC addresses
➕ Binary Addition (8-bit)
- Add bits like normal numbers.
- Carry over 1 if sum ≥ 2.
Example:
11001101
+ 01010111
-----------
100100100 → 9 bits (overflow!)
⚠️ Overflow
- Occurs when result > max value for bit size
- 8-bit max =
255
(11111111) - If result requires 9 bits → overflow
🔁 Binary Shifts
Type | Effect | Example (8-bit) |
---|---|---|
Left shift | Multiplies by 2 | 00011001 → 00110010 |
Right shift | Divides by 2 (floor div) | 00011001 → 00001100 |
- Bits shifted out are lost
- Zeros fill the opposite end
🔁 Two’s Complement (8-bit Signed Binary)
- MSB (Most Significant Bit) = sign bit (0 = +, 1 = –)
Convert Denary to 2’s Complement:
- Convert magnitude to binary
- Pad to 8 bits
- If negative:
- Invert bits
- Add 1
Example: –18
- 18 =
00010010
- Invert →
11101101
- Add 1 →
11101110
Convert Two’s Complement to Denary:
- If MSB = 0 → convert normally
- If MSB = 1 → invert + add 1 → then add (–)
Example: 11101110
- Invert →
00010001
- Add 1 →
00010010
= 18 - Result =
–18