Reading history

Number Systems: Binary, Octal and Hexadecimal

3 min read 3 views

Place value in bases 2, 8, 10 and 16, step-by-step conversions between number systems, and binary addition with worked examples.

We count in tens because we have ten fingers. Computers count in twos because their circuits have only two states: on and off. Programmers also use base 8 and base 16 as short ways of writing long strings of binary. This lesson explains how number systems work and shows, step by step, how to convert between decimal, binary, octal and hexadecimal, and how to add binary numbers.

In this lesson you will learn

  • What a base (radix) is and how place value works
  • Converting decimal to binary by repeated division
  • Converting binary, octal and hexadecimal to decimal
  • Quick conversions between binary, octal and hexadecimal
  • Binary addition

You should know bits and bytes and powers (indices).

Bases and Place Value

The base of a number system is how many different digits it uses. Each place is worth the base times the place to its right.

SystemBaseDigitsWritten as
Decimal100–9156₁₀
Binary20, 110011100₂
Octal80–7234₈
Hexadecimal160–9, A–F (A=10 … F=15)9C₁₆

All four numbers in the last column are the same value, 156, written in different bases.

Any Base to Decimal

Multiply each digit by its place value (a power of the base) and add.

101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1
        = 32 + 8 + 4 + 1 = 45

375₈    = 3×64 + 7×8 + 5×1 = 192 + 56 + 5 = 253

1A3₁₆   = 1×256 + 10×16 + 3×1 = 256 + 160 + 3 = 419

Decimal to Binary

Divide by 2 again and again, writing down each remainder. Then read the remainders from the bottom up.

Number÷ 2Remainder45→ 22122→ 11011→ 515→ 212→ 101→ 01readupwards45₁₀ = 101101₂check: 32+8+4+1 = 45
45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 =  5 remainder 1
 5 ÷ 2 =  2 remainder 1
 2 ÷ 2 =  1 remainder 0
 1 ÷ 2 =  0 remainder 1
Read upwards: 45₁₀ = 101101₂

The same method works for octal (divide by 8) and hexadecimal (divide by 16).

156 ÷ 16 = 9 remainder 12 (C)
  9 ÷ 16 = 0 remainder 9
Read upwards: 156₁₀ = 9C₁₆

Binary to Octal and Hexadecimal

Because 8 = 2³ and 16 = 2⁴, there is a shortcut. Group the binary digits from the right, in threes for octal or fours for hexadecimal, and convert each group.

Binary to octal (groups of 3):
110101₂ → 110 | 101 → 6 | 5 → 65₈

Binary to hexadecimal (groups of 4):
11010110₂ → 1101 | 0110 → D | 6 → D6₁₆

Hex to binary (each digit becomes 4 bits):
9C₁₆ → 1001 | 1100 → 10011100₂

Add zeros at the left if the last group is short: 10011100₂ in octal groups is 010 | 011 | 100 → 234₈.

Binary Addition

Rules

0 + 0 = 0    0 + 1 = 1    1 + 1 = 10 (write 0, carry 1)    1 + 1 + 1 = 11 (write 1, carry 1)

carry     1 1 1 1
            1 1 0 1     (13)
          + 1 0 1 1     (11)
          ---------
          1 1 0 0 0     (24)

Where You See These Systems

  • Binary: everything inside the computer, from numbers to pictures.
  • Hexadecimal: colour codes in web pages, such as #FF0000 for pure red (FF = 255), and memory addresses.
  • Octal: file permissions on Linux, such as 755.

Common Mistakes

  1. Reading remainders top-down. Always read from the last remainder up to the first.
  2. Grouping from the left. Group binary digits starting from the right-hand end.
  3. Using the digit 8 in octal or 2 in binary. Each base only uses digits smaller than itself.
  4. Forgetting that A–F stand for 10–15. 1A₁₆ is 26, not “1 and A”.

Practice Exercises

Exercise 1. Convert 200₁₀ to binary and to hexadecimal.

Show answer

Binary: 11001000₂. Grouping in fours: 1100 | 1000 → C8₁₆. Check: 12 × 16 + 8 = 200.

Exercise 2. Add 1011₂ + 0110₂ and check in decimal.

Show answer

1011₂ + 0110₂ = 10001₂. In decimal: 11 + 6 = 17, and 10001₂ = 16 + 1 = 17.

Frequently Asked Questions

What is the largest number one byte can hold?

Eight bits all set to 1, which is 11111111₂ = 255, or FF in hexadecimal. So one byte can hold 256 different values, from 0 to 255.

How do computers store negative numbers?

Most use a method called two’s complement, where the leftmost bit shows the sign. You will meet it in HSC ICT and in programming courses.

Summary

  • The base tells how many digits a system uses; place values are powers of the base.
  • To decimal: multiply digits by place values and add.
  • From decimal: divide repeatedly and read remainders upwards.
  • Group binary in threes for octal and fours for hexadecimal.

Next: Operating Systems and Software.

Lessons are also marked complete when you click Next.

Leave a Reply

Your email address will not be published. Required fields are marked *