UNIHIVE

Study Hub UNIPORT CSC 180.1

CSC 180.1 · Introduction to Computer Science and BASIC Programming

Number systems

Decimal, binary, octal and hexadecimal, place value, and converting between bases.

Our notes

1 min read

Place value

In any base b, a digit's value is digit × b^position, counting positions from 0 at the right.

SystemBaseDigits
Decimal100-9
Binary20, 1
Octal80-7
Hexadecimal160-9, A(10), B(11), C(12), D(13), E(14), F(15)

Computers use binary because electronic switches have two states (on/off).

Any base to decimal: multiply by powers

101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 45₁₀.
57₈ = 5×8 + 7 = 47₁₀.
2F₁₆ = 2×16 + 15 = 47₁₀.
Fraction: 0.101₂ = 1/2 + 0/4 + 1/8 = 0.625₁₀.

Decimal to any base: repeated division

Divide by the base, keep the remainders, read them from bottom to top.
45 to binary:

÷2quotientremainder
45221
22110
1151
521
210
101

Reading upward: 101101₂.
Decimal fraction to binary: multiply by 2 and keep the whole parts, reading downward: 0.625 × 2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1): 0.101₂.

Binary, octal and hex shortcuts

  • Binary to octal: group bits in threes from the right. 101101 → 101 101 → 55₈ (check: 5×8+5 = 45 ✓).
  • Binary to hex: group in fours. 101101 → 0010 1101 → 2D₁₆ (2×16+13 = 45 ✓).
  • Hex to binary: each hex digit becomes four bits. A7₁₆ = 1010 0111₂ = 167₁₀.

Exams usually ask

  • Convert numbers between decimal, binary, octal and hexadecimal (including fractions).
  • Explain why computers use the binary system.

Common mistake

Reading the remainders from top to bottom. For whole numbers read them upward (the last remainder is the most significant bit).

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 180.1 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.