Step-by-Step Decimal To Binary Conversion Tutorial
Converting decimal (base-10) numbers to binary (base-2) is a fundamental skill in computing. This tutorial shows clear, actionable methods with examples and practice problems.
How binary works (quick)
- Binary digits (bits): only 0 or 1.
- Place values: rightmost bit = 2^0, next = 2^1, then 2^2, etc.
- Example: 1101₂ = 1·2^3 + 1·2^2 + 0·2^1 + 1·2^0 = 8+4+0+1 = 13₁₀.
Method 1 — Repeated division (standard)
- Divide the decimal number by 2.
- Record the remainder (0 or 1).
- Set the quotient as the new number and repeat until quotient = 0.
- Binary is the remainders read bottom-to-top (last remainder is MSB).
Example: Convert 37₁₀ to binary
- 37 ÷ 2 = 18 remainder 1
- 18 ÷ 2 = 9 remainder 0
- 9 ÷ 2 = 4 remainder 1
- 4 ÷ 2 = 2 remainder 0
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1 Read remainders bottom-to-top: 100101₂
Method 2 — Subtract highest power of two
- Find largest 2^k ≤ N.
- Put 1 in that position, subtract 2^k from N.
- For next lower power, put 1 if it fits, else 0. Repeat until 2^0.
Example: Convert 37₁₀
- Largest power ≤37 is 32 (2^5) → 1, remainder 5
- 2^4=16 >5 → 0
- 2^3=8 >5 → 0
- 2^2=4 ≤5 → 1, remainder 1
- 2^1=2 >1 → 0
- 2^0=1 ≤1 → 1 Result: 100101₂
Method 3 — Using bitwise operations (programming)
- In many languages: repeatedly take N & 1 for least significant bit, then N >>= 1 until N = 0. Collect bits and reverse.
- Example (Python):
python
def dec_to_bin(n): if n == 0: return “0” bits = [] while n: bits.append(str(n & 1)) n >>= 1 return “.join(reversed(bits))
Fractional decimals (optional)
To convert fractional part (0.) to binary:
- Multiply fractional part by 2.
- Integer part of result is next binary digit (0 or 1).
- Keep fractional remainder and repeat until remainder = 0 or desired precision reached.
Example: 0.625
- 0.625×2 = 1.25 → bit 1, remainder 0.25
- 0.25×2 = 0.5 → bit 0, remainder 0.5
- 0.5×2 = 1.0 → bit 1, remainder 0 Result: 0.101₂
Quick checks and tips
- Verify by converting binary back to decimal using place values.
- Powers of two are single 1 followed by zeros (e.g., 8 = 1000₂).
- For large numbers use programming methods to avoid error.
- Some decimals yield repeating binary fractions (like 0.1₁₀).
Practice problems
- Convert 19₁₀ → 10011₂
- Convert 255₁₀ → 11111111₂
- Convert 6.75₁₀ → 110.11₂
Answers: 1) 10011₂, 2) 11111111₂, 3) 110.11₂
Done.