Course contentsShow
Computer Science
Lesson 4 of 2,8721. Digital FoundationsFree lesson

Converting Decimal to Binary

Use the division-by-2 method to convert decimal numbers into binary representation.

Converting Decimal to Binary

What you'll learn: How to transform everyday decimal numbers into their binary equivalents using a simple, repeatable method.

The Core Idea

You already know how to read binary and convert it back to decimal. Now let's go the other direction! The division-by-2 method works like peeling layers off an onion—each division reveals one binary digit, starting from the rightmost position.

How the Division-by-2 Method Works

Think of it this way: binary is all about powers of 2. When you divide a number by 2, the remainder tells you whether that number has a "1" or "0" in the current position. You keep dividing until there's nothing left.

Step-by-Step Example: Convert 13 to Binary

  1. 13 ÷ 2 = 6 remainder 1 ← rightmost digit
  2. 6 ÷ 2 = 3 remainder 0
  3. 3 ÷ 2 = 1 remainder 1
  4. 1 ÷ 2 = 0 remainder 1 ← leftmost digit

Now read the remainders from bottom to top: 1101

Let's verify: (1×8) + (1×4) + (0×2) + (1×1) = 8 + 4 + 1 = 13 ✓

Another Example: Convert 25 to Binary

  1. 25 ÷ 2 = 12 remainder 1
  2. 12 ÷ 2 = 6 remainder 0
  3. 6 ÷ 2 = 3 remainder 0
  4. 3 ÷ 2 = 1 remainder 1
  5. 1 ÷ 2 = 0 remainder 1

Reading bottom-to-top: 11001

Check: (1×16) + (1×8) + (0×4) + (0×2) + (1×1) = 16 + 8 + 1 = 25 ✓

Why It Works

Each division by 2 essentially asks: "Is this number odd or even?" If odd, there's a 1 in that binary position; if even, there's a 0. You're literally decomposing the number into its powers-of-2 building blocks.

Key Takeaway: To convert decimal to binary, repeatedly divide by 2 and collect remainders—then read them backwards (bottom to top) to get your binary number.