Introduction: Converting Numbers From Decimal to Binary
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.
Step 1: Create a List of Doubles
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.
Step 2: First Bit
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.
Step 3: Placing the 1's
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.
Step 4: Placing the 0's
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.
Step 5: Finish
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.
We have a be nice policy.
Please be positive and constructive.