Computer Science
Basic

Decimal to Binary

Convert a decimal number to binary by dividing by 2 and reading remainders.

Formula

N=repeated division by 2N = \text{repeated division by } 2

Variables

NDecimal number

Example

13 = 1101₂

How it works

Binary is a place-value system with only two digits, 0 and 1, so every decimal number must be rewritten as a sum of powers of 2. Repeated division by 2 works because each division step separates the number into a quotient and a remainder: the remainder tells you whether the current power of 2 is needed (1) or not (0). Reading the remainders from bottom to top gives the binary digits in the correct order.

When to use it

Use this when converting a whole number from base 10 into binary for computer science, digital electronics, or low-level programming. It is also useful when understanding how memory addresses, bit patterns, and machine data are represented.

Worked example, step by step

Convert 22 to binary:

22 ÷ 2 = 11 remainder 0

11 ÷ 2 = 5 remainder 1

5 ÷ 2 = 2 remainder 1

2 ÷ 2 = 1 remainder 0

1 ÷ 2 = 0 remainder 1

Read the remainders from bottom to top: 10110₂

So, 22 = 10110₂

Common mistakes to avoid

  • Reading the remainders from top to bottom instead of bottom to top
  • Forgetting to stop when the quotient reaches 0
  • Mixing up the quotient and remainder at each division step

Did You Know?

Repeatedly dividing by 2 and reading the remainders bottom-up converts any number to binary.

Share this formula

Educational examples use simplified assumptions. Check units and applicability before using a result; health, financial and safety decisions need appropriate professional guidance. About FormulaWon · Report a correction