Learn

Another method we can use to convert numbers from one base to another is using what is known as the division method. In the division method, we divide a decimal number by the value of the base as many times as possible until it equals 0. At each division, we note the remainder which will become the value of the digit in the new base representation.

For example, let’s convert the decimal number 536 to binary. As mentioned before, we will divide 536 as many times as needed (keeping track of the remainders) until we hit 0. From there, we will use those remainders, which will all be 0 or 1 since we are dividing by 2, to create our new binary number.

Division by 2 Remainder
536 / 2 = 268 0
268 / 2 = 134 0
134 / 2 = 67 0
67 / 2 = 33 1
33 / 2 = 16 1
16 / 2 = 8 0
8 / 2 = 4 0
4 / 2 = 2 0
2 / 2 = 1 0
1 / 2 = 0 1

Now we can construct our binary number using the remainder values (from bottom to top in our table) as 0b1000011000.

Instructions

1.

What is decimal 227 in binary?

Assign the value to checkpoint_1 in the code editor. Remember to include any necessary prefix.

2.

What is decimal 184 in binary?

Assign the value to checkpoint_2 in the code editor. Remember to include any necessary prefix.

3.

What is decimal 31 in binary?

Assign the value to checkpoint_3 in the code editor. Remember to include any necessary prefix.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?