SECTION 06 / 8

Other Bases — Octal, Hexadecimal and Any Base

5 min read
On this page 10 headings

Start here Binary numbers get long very fast: 1011011011101110 is hard to read and easy to copy wrong. So engineers use a short form called hexadecimal, where every 4 bits become one symbol. That number is just 0xB6EE. You’ll see “0x…” all over this course: in control words, machine code and memory addresses.

Any base works the same way

In base b, each place is worth b times the place to its right, and the digits go from 0 to b − 1.

Base Name Digits Place values (right to left)
2 Binary 0, 1 1, 2, 4, 8, 16 …
8 Octal 0–7 1, 8, 64, 512 …
10 Decimal 0–9 1, 10, 100 …
16 Hexadecimal (hex) 0–9, A–F 1, 16, 256, 4096 …

In hex, the letters stand for: A=10,B=11,C=12,D=13,E=14,F=15A = 1 0 , B = 1 1 , C = 1 2 , D = 1 3 , E = 1 4 , F = 1 5.

Rule: a digit can never be equal to or bigger than its base. “(143)₄” is impossible, because base 4 has no digit 4.

Hex ↔︎ binary: groups of 4

Every hex digit is exactly 4 bits. Split binary into groups of 4 from the right.
Every hex digit is exactly 4 bits. Split binary into groups of 4 from the right.
Open image ↗
Hex and binary

Since 16 = 2⁴, one hex digit = 4 bits. (Octal: one digit = 3 bits, since 8 = 2³.)

Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

In one line: Every base works by place value (each place = base × the one to its right). Hex uses 0–9 and A–F, and each hex digit is exactly 4 bits. Exam words: base (radix), octal, hexadecimal, 0x prefix, A–F, nibble (4 bits), place value.


How to solve: base questions (these come in every Quiz 1)

Type 1: any base → decimal

Steps: multiply each digit by its place value (1,b,b2,…)\left(1 , b , b^{2} , \ldots \right) and add. Example: (431)₆ = 4×36 + 3×6 + 1×1 = 144 + 18 + 1 = 163

Type 2: decimal → any base

Steps: divide by the base again and again, and read the remainders from bottom to top (same as for binary, just a different divisor). Example: 163 → hex: 163 ÷ 16 = 10 remainder 3; 10 ÷ 16 = 0 remainder 10 (A) → 0xA3

Exam pattern: “A number in base 6 is 431. What is its hex form?” Go base 6 → decimal → hex: 431₆ = 163 = A3.

Type 3: binary ↔︎ hex

Steps (binary → hex): group the bits in 4s from the right (add 0s on the left if needed), then change each group to one hex digit. Example: 101111 → 0010 1111 → 2F Steps (hex → binary): write each hex digit as 4 bits. 0xDE → 1101 1110.

Trap: group from the right. Grouping from the left gives a wrong answer.

Type 4: find the unknown bases

Example (real Quiz 1 pattern): if (143)ₐ = (212)ᵦ, find a and b.

Steps:

  1. Write both sides in decimal: a2+4a+3=2b2+b+2a^{2} + 4 a + 3 = 2 b^{2} + b + 2.
  2. Try the answer options one by one, and pick the one where both sides are equal:
    • a=6,b=5:36+24+3=a = 6 , b = 5 : 3 6 + 2 4 + 3 = 63; 50 + 5 + 2 = 57, not equal ✗
    • a=7,b=6:49+28+3=a = 7 , b = 6 : 4 9 + 2 8 + 3 = 80; 72 + 6 + 2 = 80 ✓

Answer: a=7,b=6a = 7 , b = 6.

Tips:

  • Don’t solve the equation by algebra in the exam. Testing the options is faster and safe.
  • In true maths, each base must be bigger than its largest digit. But one past paper accepted an answer that breaks this rule (see “Try these” no. 3), so trust the equation over the digit rule.

Type 5: minimum bits to write a number

“How many bits are needed to write the number 128 in binary?”

  • 128 = 10000000₂ → 8 bits.
  • Quick rule: the number N needs n bits where 2n−1≤N2^{n-1} \le N < 2ⁿ. For 128: 2⁷ = 128 ≤ 128 < 256=28→n=2 5 6 = 2^{8} \to n = 8.

Trap: this is different from “how many bits for 128 different values” (that’s 7 bits, values 0–127). Read the question carefully: a number vs a count of things.

Try these

  1. Convert (777)₈ to decimal.
7×64 + 7×8 + 7 = 448 + 56 + 7 = 511.
  1. Convert 11011110₂ to hex.
1101 1110 → D E → 0xDE.
  1. If (234)ₐ = (143)ᵦ, find a and b (options: a=3,b=4/a=4,b=5/a=5,b=6/a=6,b=7/a=7,b=8a = 3 , b = 4 / a = 4 , b = 5 / a = 5 , b = 6 / a = 6 , b = 7 / a = 7 , b = 8).
Equation: 2a2+3a+4=b2+4b+32 a^{2} + 3 a + 4 = b^{2} + 4 b + 3. Only a=4,b=5a = 4 , b = 5 works (48 = 48), and that was the official answer (2025 Term 3, Quiz 1). Strictly, the digit 4 can’t appear in base 4, so the question is slightly flawed. In the exam, go with the option that makes both sides equal.
  1. Minimum bits to write the number 500?
256 ≤ 500 < 512 → 9 bits.

Quick check

What does the hex digit B stand for? 11 (binary 1011).
How many bits does one hex digit hold? One octal digit? Hex: 4 bits. Octal: 3 bits.
Can(148)6C a n \left(1 4 8\right)_{6} be a valid number? No. Base 6 only has digits 0–5, and 8 is not allowed.
YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑