Menu
Coddy logo textTech

Decimal to Binary

Part of the Fundamentals section of Coddy's Assembly journey — lesson 9 of 45.

Now that you know how binary works, you need to learn how to convert a decimal number (like 13) into binary (1101).

The method: divide by 2 repeatedly, read remainders backward.

Step-by-step example: Convert 13 to binary

StepDivisionResultRemainder
113 ÷ 261
26 ÷ 230
33 ÷ 211
41 ÷ 201

Now read the remainders from bottom to top: 1101

So 13 in decimal = 1101 in binary.

Another example: Convert 25 to binary

StepDivisionResultRemainder
125 ÷ 2121
212 ÷ 260
36 ÷ 230
43 ÷ 211
51 ÷ 201

Read bottom to top: 11001

So 25 in decimal = 11001 in binary.

Why this works:

Each time you divide by 2, you are finding the next binary digit (starting from the rightmost). The remainder tells you whether that digit is 0 or 1. You stop when the result becomes 0.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals