UNIHIVE

Study Hub UNIPORT IFT 211

IFT 211 · Digital Logic Design

Number systems and conversions

Binary, octal, decimal and hexadecimal, and how to convert whole numbers and fractions between them.

Our notes

1 min read

Positional number systems

In base b, each digit is multiplied by a power of b. In decimal 352 = 3 × 10² + 5 × 10 + 2. The bases used in computing:

  • Binary (base 2): digits 0, 1.
  • Octal (base 8): 0 to 7.
  • Decimal (base 10).
  • Hexadecimal (base 16): 0 to 9 then A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

Binary to decimal

Add the place values of the 1s.

  • 1011 0110₂ = 128 + 32 + 16 + 4 + 2 = 182.
  • Fractions use negative powers: 0.101₂ = 0.5 + 0.125 = 0.625.

Decimal to binary

  • Whole part: divide by 2 repeatedly and read the remainders from the bottom up.
  • Fraction part: multiply by 2 repeatedly and read the whole-number parts from the top down.

Worked example

Convert 45.375 to binary.

  • 45 ÷ 2 = 22 r 1; 22 ÷ 2 = 11 r 0; 11 ÷ 2 = 5 r 1; 5 ÷ 2 = 2 r 1; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Reading up: 101101.
  • 0.375 × 2 = 0.75 (0); 0.75 × 2 = 1.5 (1); 0.5 × 2 = 1.0 (1). Reading down: .011.
  • Answer: 101101.011₂. Check: 32 + 8 + 4 + 1 + 0.25 + 0.125 = 45.375.

Binary, octal and hex shortcuts

Since 8 = 2³ and 16 = 2⁴, group bits from the binary point.

  • Octal: groups of 3. 101 101.011 = 55.3₈.
  • Hex: groups of 4. 0010 1101.0110 = 2D.6₁₆.
  • Hex to binary: write each digit as 4 bits. 3F₁₆ = 0011 1111 = 63.

Worked example

Convert 2AF₁₆ to decimal: 2 × 256 + 10 × 16 + 15 = 512 + 160 + 15 = 687.

Fractions that never end

0.1 in decimal is 0.0001100110011… in binary, a repeating pattern. Computers store a rounded value, which is why 0.1 + 0.2 is not exactly 0.3 in many programming languages.

Exams usually ask

  • Convert between any two bases, including fractions.
  • Explain why hexadecimal is used (short, easy to turn into binary).

Common mistake

Reading the remainders of repeated division from the top down: that gives the bits in reverse order.

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

Read

Watch

Practise

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 IFT 211 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.