Number Systems
- Binary (Base 2): uses only the digits 0 and 1.
- Definition: the native number system of digital computers — each binary digit (bit) maps directly to one of two physical states (on/off, high/low voltage).
- How it's used: all data, instructions, and addresses are ultimately stored and processed in binary inside the hardware.
- Example: (1100)₂ = 12 in decimal.
- Octal (Base 8): uses digits 0–7.
- Definition: each octal digit represents exactly 3 binary bits, since 2³ = 8.
- How it's used: a compact shorthand for binary, historically used in older computing systems; still seen in Unix file permission notation (e.g.,
chmod 755).
- Example: (17)₈ = 15 in decimal.
- Decimal (Base 10): uses digits 0–9.
- Definition: the standard number system humans use day to day; not native to computer hardware.
- How it's used: numbers are converted to/from binary at the human–computer boundary so users can work in a familiar system.
- Example: (156)₁₀.
- Hexadecimal (Base 16): uses digits 0–9 plus letters A–F (representing values 10–15).
- Definition: each hex digit represents exactly 4 binary bits (a nibble), since 2⁴ = 16.
- How it's used: a compact, human-readable stand-in for binary — used for memory addresses, colour codes (e.g.,
#FF0000), and error codes.
- Example: (9C)₁₆ = 156 in decimal.
Conversions
General Rule (Positional Notation)
Every number system works on the same underlying equation — this is the one formula that explains every conversion below:
- Formula: N = dₙ×bⁿ + ... + d₁×b¹ + d₀×b⁰ (+ d₋₁×b⁻¹ + ... for fractional digits)
- where b = the base (2 for binary, 8 for octal, 10 for decimal, 16 for hex) and dᵢ = the digit at position i, counted from 0 at the rightmost digit.
- This single formula IS "any base → decimal" conversion; converting decimal → any base is just the reverse process (repeated division).
1. Decimal → Binary (Base 10 → Base 2)
- Method: repeated division by 2, reading remainders bottom-to-top.
- Worked example: convert (156)₁₀ → binary
- 156 ÷ 2 = 78, remainder 0
- 78 ÷ 2 = 39, remainder 0
- 39 ÷ 2 = 19, remainder 1
- 19 ÷ 2 = 9, remainder 1
- 9 ÷ 2 = 4, remainder 1
- 4 ÷ 2 = 2, remainder 0
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
- Read remainders bottom-to-top: (156)₁₀ = (10011100)₂
2. Binary → Decimal (Base 2 → Base 10)
- Formula: N₁₀ = Σ (bitᵢ × 2ⁱ)
- Worked example: convert (10011100)₂ → decimal
- = 1×2⁷ + 0×2⁶ + 0×2⁵ + 1×2⁴ + 1×2³ + 1×2² + 0×2¹ + 0×2⁰
- = 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = (156)₁₀
3. Decimal → Octal (Base 10 → Base 8)
- Method: repeated division by 8, reading remainders bottom-to-top.
- Worked example: convert (156)₁₀ → octal
- 156 ÷ 8 = 19, remainder 4
- 19 ÷ 8 = 2, remainder 3
- 2 ÷ 8 = 0, remainder 2
- Read bottom-to-top: (156)₁₀ = (234)₈
4. Octal → Decimal (Base 8 → Base 10)