loading

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.

Very confusing. I want to learn this but your instructions were not clear
<p>Each bit can only be on or off and the number of the bit starting at at 0 is what you raise 2 to the power of to get the value of the bit. Yeah it's confusing but here:</p><p>2^0 = 1</p><p>2^1 = 2</p><p>2^2 = 4</p><p>2^3 = 8</p><p>So on and so forth.</p><p>Now to represent the bits. From right to left starting at 0 is the number of the bit</p><p>8 4 2 1 &lt;~ Values</p><p>- - - -</p><p>4 3 2 1 &lt;~ Bit number</p><p>Now to convert a number, 15 or less since thats the max of my current example, you figure out the largest number that could possibly fit into your decimal number. I'm going to use 9 in my example.</p><p>Look at the first value of our small table, 8. Does eight fit into 9? Yes it does so you turn that bit on and subtract 8 from the value.</p><p>9-8=1</p><p>and atm our display looks like</p><p>1 * * *</p><p>Now we look at the next value and subtract it if it fits, if it doesnt we turn that bit off and move to the next until we reach our target value.</p><p>4 &lt;= 1 not true so the bit is off</p><p>10**</p><p>2 &lt;= 1 not true so the bit is off again.</p><p>100*</p><p>1 &lt;= 1 is true so the last bit is on.</p><p>0b1001 = 0d9</p><p>hope that helped... sorry its so long</p>
<p>Sorry about that. This is my first iteration. I expect to edit it within a week or two. What in particular was confusing?</p>

About This Instructable

1,211views

12favorites

License:

More by paul_young:Converting Numbers from Decimal to Binary 
Add instructable to: