APCS – Unit 1- Lesson 4 – Converting Decimal to Binary

In the previous lesson, we learned how to convert binary to decimal. Let’s recall the example:

Now, reverse the process, you can convert the decimal to binary.

Review the power table might help you to solve the conversion problems quicker.

Example # 1:  What binary number is equivalent to the decimal number 125?

Method #1:

To solve this problem, first rewrite the number 125 as the sum of powers of two. If you have not memorized the power table of two yet, use the table above as reference, you can get:

125 = 64 + 32 + 16 + 8 + 4 + 1

= 1(2^6) + 1(2^5) + 1(2^4) + 1(2^3) + 1(2^2) + 0(2^1) + 1( 2^0)

Therefore, the answer is 1 1 1 1 1 0 1.

Isn’t it cool?

Some people don’t like the method, since they feel that it is not easy to find the powers of two at the glance! If that’s the case, there is an alternative way to solve this problem.

Method #2:

Another way to convert decimal to binary is successive division by 2. This involves dividing the number by 2 recursively until you’re left with 0, writing down the reminder for each step, and finally reading the remainders from bottom up!

***Some images are copied from the internet.