Binary Number System — Conversion Between Binary, Decimal, Octal, Hexadecimal

medium CBSE JEE-MAIN 3 min read

Question

How do we convert numbers between binary, decimal, octal, and hexadecimal systems?


Solution — Step by Step

Each number system uses a different base:

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

The “base” tells you how many unique digits exist and the place value multiplier.

Each bit position represents a power of 2 (rightmost = 202^0).

(1101)2=1×23+1×22+0×21+1×20=8+4+0+1=(13)10(1101)_2 = 1 \times 2^3 + 1 \times 2^2 + 0 \times 2^1 + 1 \times 2^0 = 8 + 4 + 0 + 1 = (13)_{10}

Divide by 2 repeatedly, record remainders from bottom to top:

13÷2=613 \div 2 = 6 remainder 1 6÷2=36 \div 2 = 3 remainder 0 3÷2=13 \div 2 = 1 remainder 1 1÷2=01 \div 2 = 0 remainder 1

Read remainders bottom-up: (13)10=(1101)2(13)_{10} = (1101)_2

Binary to Octal: Group bits in threes from right: (110101)2=(110)(101)=(65)8(110101)_2 = (110)(101) = (65)_8

Binary to Hex: Group bits in fours from right: (110101)2=(0011)(0101)=(35)16(110101)_2 = (0011)(0101) = (35)_{16}

Reverse for Octal/Hex to Binary: replace each digit with its 3-bit (octal) or 4-bit (hex) binary equivalent.

graph TD
    A[Number Conversion] --> B{From what to what?}
    B -->|Binary to Decimal| C[Multiply each bit by 2^position, add]
    B -->|Decimal to Binary| D[Divide by 2 repeatedly, read remainders up]
    B -->|Binary to Octal| E[Group bits in 3s from right]
    B -->|Binary to Hex| F[Group bits in 4s from right]
    B -->|Octal to Binary| G[Replace each octal digit with 3 bits]
    B -->|Hex to Binary| H[Replace each hex digit with 4 bits]
    B -->|Decimal to Octal/Hex| I[Convert to binary first, then group]

Why This Works

Number systems are just different ways of representing the same quantity. Binary uses powers of 2 because computers use on/off switches (two states). Octal and hex are convenient shorthands for binary — 3 binary digits map perfectly to 1 octal digit, and 4 binary digits map to 1 hex digit. This is why programmers prefer hex over decimal for representing binary data.


Alternative Method

For decimal to binary, you can also use the “subtract largest power of 2” method. For 13: largest power of 2 that fits = 8 (232^3). Remainder = 5. Next: 4 (222^2). Remainder = 1. Next: 1 (202^0). Place 1s in positions 3, 2, 0 and 0 elsewhere: 11011101.


Common Mistake

When grouping binary digits for octal or hex conversion, students often group from left to right instead of right to left. Always start grouping from the rightmost bit. If the leftmost group is incomplete, pad with leading zeros. For example, (10111)2(10111)_2 for octal: group as (010)(111)=(27)8(010)(111) = (27)_8, not (101)(110)(101)(110).

Want to master this topic?

Read the complete guide with more examples and exam tips.

Go to full topic guide →

Try These Next