Nhật's Blog

Binary and Decimal Number System Conversion

April 26, 2026Trịnh Minh Nhật

A complete guide to converting between binary (base-2) and decimal (base-10) number systems, with step-by-step examples and algorithms.

Introduction

Every piece of data inside a computer — text, images, audio, instructions — is ultimately represented as a sequence of 0s and 1s. This is the binary (base-2) number system. As humans, we naturally think in decimal (base-10). Knowing how to move between the two systems is a foundational skill in computer science.


Binary to Decimal

Binary is a positional number system where each digit (bit) represents a power of 2, starting from the rightmost position (position 0).

Method: Positional Value (Powers of 2)

For a binary number bnbn1b1b0b_n b_{n-1} \ldots b_1 b_0:

Decimal=bn×2n++b1×21+b0×20\text{Decimal} = b_n \times 2^n + \cdots + b_1 \times 2^1 + b_0 \times 2^0

Example 1 — Convert 1011 to decimal

Position3210
Bit1011
Value2³=82²=42¹=22⁰=1

1×8+0×4+1×2+1×1=8+0+2+1=111 \times 8 + 0 \times 4 + 1 \times 2 + 1 \times 1 = 8 + 0 + 2 + 1 = \mathbf{11}

Example 2 — Convert 11010110 to decimal

Position76543210
Bit11010110
Value1286432168421

128+64+0+16+0+4+2+0=214128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = \mathbf{214}


Decimal to Binary

Method: Repeated Division by 2

  1. Divide the decimal number by 2.
  2. Record the remainder (0 or 1).
  3. Use the quotient as the next number to divide.
  4. Repeat until the quotient is 0.
  5. Read the remainders from bottom to top — that is your binary result.

Example 1 — Convert 13 to binary

StepNumber÷ 2QuotientRemainder
113÷ 261
26÷ 230
33÷ 211
41÷ 201

Read remainders bottom-to-top: 1101

Verify: 8+4+0+1=138 + 4 + 0 + 1 = 13

Example 2 — Convert 214 to binary

StepNumberQuotientRemainder
12141070
2107531
353261
426130
51361
6630
7311
8101

Read bottom-to-top: 11010110

Verify: 128+64+0+16+0+4+2+0=214128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214


Quick Reference Table (0–15)

DecimalBinaryDecimalBinary
0000081000
1000191001
20010101010
30011111011
40100121100
50101131101
60110141110
70111151111

Tips & Common Mistakes

Reading direction matters. When you collect remainders during division, always read from the last remainder to the first (bottom-to-top). Reversing this is the most common error.

Leading zeros. In practice, binary numbers are often padded to a fixed width (e.g., 8-bit: 00001101). The leading zeros don't change the value.

Verify your work. After converting decimal → binary, quickly convert back using the positional method to confirm you get the original number.

Powers of 2 cheat sheet:

2⁰2⁴2⁵2⁶2⁷2⁸2⁹2¹⁰
12481632641282565121024

Summary

DirectionMethodKey Step
Binary → DecimalPositional valueMultiply each bit by its power of 2, then sum
Decimal → BinaryRepeated division by 2Collect remainders, read bottom-to-top

Once you are comfortable with base-2 and base-10, expanding to hexadecimal (base-16) — the system used in memory addresses, color codes, and debugging — becomes straightforward.