## Intro: Convert Decimal to Binary and Vice Versa

This is a technique that helped me out a lot when learning about AND OR NOR gates, creating subnet masks and helped me pass time seeing how high I could get with the binary sequence (not very far). I was able to teach my son this method when he was 7 or 8.

I plan to eventually make this a Computer Science Collection of Instructables to help teach kids. If anyone would like to help out, provide suggestions and/or write Instructables for this collection let me know.

I keep seeing my Assembly Language Quick Reference Guide on my desk.... There's nothing quick about Assembly at least not for me.

## Step 1: Binary Sequence

The key to this method is laying out the numbers binary sequence which is powers of 2 since binary is base 2. This that much more difficult than counting by 2's. Note that we use base 10 considering we have 10 digits and computers at their lowest level use base 2. People argue that some computers use base 16 but remember that a switch is either on or off, 1 or 0. The numbers will need to be from right to left the lowest number to the highest number. This is illustrated by the second picture in the collection.

## Step 2: Binary to Base 10

Here we will use the sequence table (2nd Image) to find the base 10 number. Use the visual (1st image) to get a better idea of how this works.

So here you have a given binary number.

- You will fill in the table from right to left with the 1's & 0's from the binary number.
- You will find the decimal numbers that have a 1 and not a zero. Remember that 1 is on and 0 is off.
- Add the decimal numbers you found in the previous step together to get the decimal value of the binary number that you were given.

## Step 3: Decimal to Binary

Here we will use the sequence table (2nd Image) to find the base 2 number. Use the visual (1st image) to get a better idea of how this works.

So here you have a given decimal (base 10) number.

- Find the highest number that will go into your given decimal number.
- Place a 1 in the table for each number that you were able to subtract.
- Subtract that number from your decimal number.
- Find the next highest number that will go into the number from number 3.
- Repeat steps 1-5 until you have a zero remainder.
- Your binary number will not start with zero but everywhere else that you have a blank fill in a zero (see example)

## 9 Discussions

3 years ago on Introduction

Oh so many memories from my Computer Architecture class. Writing in assembly isn't the most fun or happiest of things.

But this is definitely a good way of doing this!

Reply 3 years ago on Introduction

At one point I felt that if I loaded one more binary digit into a register I would surely go mad.

Reply 3 years ago on Introduction

Make that "01 more digit..." :)

Reply 3 years ago

Yes! So much yes!

3 years ago on Introduction

It's good for kids to do this kind of exercise a few times so they understand the logic behind number system relationships, but for actual coding I'd want them to use a calculator for conversions.

Reply 3 years ago on Introduction

I don't disagree. My motive is for kids to have a good solid foundation.

Reply 3 years ago on Introduction

Same basic idea with any form of math. Kids should not do their work on a calculator until they know how to solve problems "manually", which requires them to understand the logic of problem solving.

3 years ago on Introduction

What no hex? Where's the hex. Like tomato says, "Oh so many memories..."

Reply 3 years ago on Introduction

Haha I have to review it before I finish up the hex instructions. The binary was easy because I had committed it to memory.