Converting Numbers From Decimal to Binary

by paul_young in Circuits > Software

1738 Views, 12 Favorites, 0 Comments

Converting Numbers From Decimal to Binary

20140329_144452.jpg

Digital logic circuits make up the computing systems for almost all electronics. Digital logic primarily works with two states, high and low. These states are often referred to as 1 (high) and 0 (low). Because of this, when dealing with digital logic, it is often beneficial to represent numbers in binary form so they can be presented to the circuitry as a string of 1’s and 0’s. While many resources exist to do these conversions, it is helpful to know how to do them by hand. For simplicity, this guide will only cover conversion of positive integers (i.e. whole numbers).

To begin, you will need a sheet of paper and a pen or pencil.

This example will convert the number 19 to its binary representation.

Create a List of Doubles

2014-04-07 08.19.39.jpg

The first step is to create a list of numbers to use when performing the conversion.

Going from right to left, create a list of numbers beginning at 1 with each element twice as large as the previous element (1, 2, 4, etc.)

Continue this process until you write a number larger than the number you want to convert to binary.

Example: 32 is greater than 19, so the list stops at 32.

First Bit

2014-04-07 09.03.51.jpg

Find the largest number in the list that is still smaller than the number you want to convert and place a 1 under it.

Then subtract that number from the number you wish to convert to binary.

You will use the difference in the next step.

Placing the 1's

2014-04-07 09.04.58.jpg

Now do the same thing with the difference you calculated in the previous step. Find the largest number in the list that is smaller than the difference from the previous step and place a 1 under it.

Subtract this number from the difference you previously calculated.

Repeat this step until the difference you calculate becomes 0.

Placing the 0's

2014-04-07 09.05.32.jpg

Place 0's under each of the numbers in the list which do not have 1's under them. You may ignore the leftmost number since a 0 on the left does not affect the value of the number.

Finish

2014-04-07 09.06.15.jpg

Finally, put together the string of 1's and 0's that you created.

This is the binary representation of your number.

Representing negative numbers in binary is almost exclusively done by using 2's complement. If you would like to learn how to do this, here is a good set of instructions on how to do that: http://www.cs.cornell.edu/~tomf/notes/cps104/twos...

Here is a website you can go to to test if you did the conversion correctly: http://www.mathsisfun.com/binary-decimal-hexadecim... Simply type in the number and it gives the binary form.