Return to Home Page       Return to Instructional Calendar

Computer Math & Non-Decimal Number Systems

How to count, convert, and compute in Binary (base-2), Octal (base-8), and Hexadecimal (base-16).

1) Why different bases?

Place Value Pattern

Base Positions (right→left)
Binary (2) 2⁰, 2¹, 2², 2³, …
Octal (8) 8⁰, 8¹, 8², 8³, …
Hex (16) 16⁰, 16¹, 16², 16³, …

Digits Allowed

Base Digits
Binary 0–1
Octal 0–7
Hex 0–9, A–F (A=10 … F=15)

2) Counting Examples

Binary (base-2)

Carry when you reach 2 (just like carry at 10 in decimal).

Decimal Binary
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000

Octal (base-8)

Digits go 0–7, then carry.

Decimal Octal
0 0
1 1
7 7
8 10
9 11
15 17
16 20

Hexadecimal (base-16)

After 9 comes A(10), B(11), C(12), D(13), E(14), F(15), then 10.

Decimal Hex
0 0
9 9
10 A
11 B
12 C
13 D
14 E
15 F
16 10

3) Conversions

Decimal → Any Base (Repeated Division)

  1. Divide by the base, record the remainder.
  2. Repeat on the quotient until it is 0.
  3. Read remainders from last to first.
Example: 45 (decimal) → binary
45 ÷ 2 = 22 r1 → 22 ÷ 2 = 11 r0 → 11 ÷ 2 = 5 r1 → 5 ÷ 2 = 2 r1 → 2 ÷ 2 = 1 r0 → 1 ÷ 2 = 0 r1
Answer: 101101₂

Any Base → Decimal (Place Value)

Multiply each digit by its place value and sum.

Example: 2F₁₆ → decimal
2×16¹ + 15×16⁰ = 32 + 15 = 47

Binary ⇄ Octal (group by 3)

Group binary bits in 3s (from the right). Each group is one octal digit.

Example: 1101011₂ → group as 1 101 011 → pad to 001 101 0111 5 3153₈

Binary ⇄ Hex (group by 4)

Group binary bits in 4s (from the right). Each group is one hex digit.

Example: 1011 0110₂B6₁₆

4) Arithmetic

Binary Addition

a b sum carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Example: 10101₂ + 00111₂ = 11100₂

Octal & Hex Addition

Add digit-wise. If a column ≥ base, write remainder and carry 1 to the next column.

Octal: 57₈ + 26₈ = 105₈
Hex: 2A₁₆ + 1F₁₆ = 49₁₆

Subtraction (Borrow)

Borough from the next higher place if needed (base-2, base-8, or base-16).

Binary: 10010₂ − 01101₂ = 00101₂
Octal: 145₈ − 37₈ = 106₈
Hex: 3C₁₆ − 1F₁₆ = 1D₁₆

Two’s Complement (for Subtraction)

  1. To negate a binary number: invert bits (one’s complement) then add 1.
  2. Add the negated value to perform subtraction.
  3. Discard final carry if it appears.
Example: Compute 01010101₂ − 00011010₂
Negate subtrahend: 00011010 → 11100101 → 11100110
Add: 01010101 + 11100110 = 1 00111011 → discard carry → 00111011₂

5) Quick Reference

Powers

k 2^k 8^k 16^k
0 1 1 1
1 2 8 16
2 4 64 256
3 8 512 4096
4 16 4096 65536

6) Practice Problems

  1. Convert 93₁₀ to binary and hex.
  2. Convert 101111₂ to decimal and octal.
  3. Compute 110101₂ + 1110₂.
  4. Compute 7A₁₆ − 2F₁₆.
  5. Use two’s complement to evaluate 01001010₂ − 00110111₂.
Show Answers
  1. 93₁₀ = 1011101₂; 93₁₀ = 5D₁₆.
  2. 101111₂ = 47₁₀; group by 3 → 010 111 → 57₈.
  3. 110101₂ + 1110₂ = 110101₂ + 001110₂ = 1000011₂.
  4. 7A₁₆ − 2F₁₆ = (122₁₀ − 47₁₀) = 75₁₀ = 4B₁₆.
  5. 00110111 → one’s: 11001000 → plus 1: 11001001; 01001010 + 11001001 = 1 00010011 → discard carry → 00010011₂ (decimal 19).
```