Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Competitions › SOF ICSO › unit 16 of 16

Number systems: octal and hexadecimal

SOF ICSO · Computer Science · about 5 minutes

Besides binary (base 2), computers use octal (base 8) and hexadecimal (base 16). Hex digits go 0–9 then A–F (10–15).

Each hex digit is exactly 4 bits, and each octal digit is 3 bits, so converting from binary is quick.

In this lesson

  1. Place values
  2. Shortcut through binary
  3. Worked examples
  4. Where marks are lost
  5. Check yourself

1Place values

In base b, places are worth 1, b, b², b³… So (157)₈ = 1 × 64 + 5 × 8 + 7 = 111.

2Shortcut through binary

To turn hex into octal, go hex → binary (4 bits per digit) → regroup in threes → octal.

Worked examples

  1. Example 1Convert 255 to hex.

    1. 255 = 15 × 16 + 15.

    Answer: FF

See it move

Where marks are lost

  • Grouping bits from the left instead of the right.
  • Writing 10 instead of A in hex.

Exam tips

  • Group binary from the right in fours for hex, threes for octal.
  • Colours on the web are hex: #FF0000 is red.
  • (1A)₁₆ = 1 × 16 + 10 = 26.

Practice questions

  1. (2F)₁₆ in decimal is…

  2. Binary 110101 in octal is…

  3. The largest single hex digit is…

More worked examples

Try each one first, then open the working.

  1. Hex 96 in decimal?

    Show the working

    Start: Two hex digits: 16s and 1s.

    First digit × 16 + second digit (A = 10 … F = 15).

    Answer: 150

  2. Binary 110010 in decimal?

    Show the working

    Start: Rightmost bit is 1s.

    Add the place values 1, 2, 4, 8, 16, 32 where there is a 1.

    Answer: 50

  3. 27 in binary? (type the digits)

    Show the working

    Start: Find the biggest power of 2 first.

    Keep dividing by 2 and read the remainders upwards.

    Answer: 11011

  4. What is the hexadecimal number C32 in decimal?

    Show the working

    Start: Each place is worth 16 times the next.

    C×16^2 + 3×16^1 + 2×16^0 = 3122.

    Answer: 3122

Practise more

New questions every time, at exam level

Hex B0 in decimal?

Learn it properly

Full chapters with animations, each with an “Explained simply” version.

  • Number systemsClass 8

Sit a timed SOF ICSO mock test

AI and robotics basicsAll competitions