## Binary to Decimal and Decimal to Binary Conversions ## Binary to Decimal

This article was written with an aim to help those learning about the binary and decimal number bases and common conversions between them, in particular, Binary to Decimal and Decimal to Binary conversions.

It may help those studying Discrete Mathematics modules on Computer Science degrees, budding network engineers learning subnetting, and just about anyone else with an interest in this branch of Mathematics.

I will start by outlining what the number bases are and mean, then move on to the conversion methods.

What are number bases?

The base or ‘radix’ is the number of digits that are used for counting in that number system. It is usually represented as subscript beneath the element or number in question I.E a smaller number beneath the element itself.

The following are the representations of the major number bases this article explores — we have used the number as an example of the element or number in question, the smaller number beneath denotes the number base system used — this is called subscript:

Humans typically use the decimal system in most cases — that is, counting with 10 digits. Arguably and historically, humans have used this system due to a natural predisposition to count the number of digits on both hands.

We use the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 (10 digits in total) when counting in the decimal system, this is the number represented as the base/radix and is written as a subscript when we wish to make it obvious what number base was used.

What is place value?

Within all number bases, we apply place value to numbers based on their position, this affects the total value of the number(s) in question.

The rightmost digit in any sequence of numbers is known as the Least Significant Digit (LSD) and the digit farthest to the left is known as the Most Significant Digit (MSD).

For example, in the number 123,432 — spoken as one hundred and twenty-three thousand, four hundred and thirty-two — the LSD is 2 (in the units column) and the MSD is 1, in the hundred thousand columns. View the chart below for a rudimentary understanding of place value.

Note the full stop or period in this chart, denoting the decimal place: on its left-hand side is the ones or unit’s column, followed by tens, hundreds, thousands, and so on.

To the right-hand side of the decimal place are the fractional places: represented immediately to the right of the decimal point as tenths, hundredths, thousandths, and so on.

To represent the number used in the previous example — 123,432 we can place it in the place value chart as follows: Sum all these values and you will return to the figure in question.

So, the place value of the digits in the decimal system, starting in the one’s column and traversing to the left, I.E then the tens, hundreds, thousands…increases the exponent by 1 in each place move.

If you have a 3 in the tens place — the tens place itself represents 10 to the power of 1 (10¹) — you multiply that by the number in question, so 3 x 10 = 30.

Below is a useful place value chart explaining the exponent values of the base 10 number system.

If you don’t understand at this point, you may refer to the following tutorial by the British Broadcasting Corporation (BBC) on the topic, as we wish to focus on base conversions and how to complete them:

https://www.bbc.co.uk/bitesize/guides/zc634qt/revision/1

It is important to consider place value when understanding the base systems and conversions between them, as the place value used differs in value between the number bases and is consistent throughout them.

What is the binary system?

The binary number system or base 2 is used throughout computation but pre-dates the invention of modern computing. It consists of counting using only 2 digits — 1 and 0. Their place value, as already explained above, is extremely important in understanding the value of a binary number.

We use binary in computing because, on a very simplistic level, computers are only able to process two states, typically represented as the presence of charge or absence of it.

Place value in the binary system

Place value in the binary system works the same on a conceptual level — where 1 or 0 is placed changes the value of the total.

Instead of using 10 as the base number with exponents increasing incrementally, as in decimal — the base is, you guessed it, 2.

Refer to the following chart and memorize it, it is essential:

The one’s place represents 2⁰
The two’s place represents 2¹
The four’s place represents 2²
The eight’s place represents 2³
The sixteen’s place represents 2⁴
The thirty-two’s place represents 2⁵
The sixty-four’s place represents 2⁶
The one-hundred and twenty-eight’s place represents 2⁷

Note again that place value in the binary system increases exponentially — I.E it doubles in value on each increment.

Now let us consider the binary number 11000111 — please refer to the following chart to see how the place value lines up.

To compute this number, start at the Least Significant Digit (LSD).

We will refer to numbers where they are being taken the power of something in the following manner, with the element first then ^ representing the power, followed by an exponent.

We can see there is a 1 in this place, so multiply 1 by 2⁰ which equals 1, write down 1.

Then look at the next place to the left of the LSD, there is a 1 in the two’s place. This is represented as 1 x 2¹ which equals 2, write this down as an addition to the previous number.

Now you have 1 + 2, let’s continue…

There is a 1 in the fours place — this is represented as 1 x 2² which equals 4, write that down as the next addition.

You now have 1 + 2 + 4.

The next digit is a 0 in the eight’s place — this is represented as 0 x 2³ which equals 0.

Omit the 0 from the numbers you are summing so far and move on until you find the place value of the next 1.

In the sixty-fours place, we find the next 1 — this is represented as 1 x 2⁶ which equals 64.

Finally, in the one hundred twenty-eight’s place, we find 1 — this is represented as 1 x 2⁷ which equals 128.

Your final sum should look like this: 1 + 2 + 4 + 64 + 128 = 199

This is how we convert binary numbers to decimal.

If this is your first time learning this concept, I would strongly recommend practicing multiple operations of this with various exercises until you are comfortable with it and have memorized binary place values.

You can try the following calculator to convert binary to decimal and so on.

https://www.rapidtables.com/convert/number/binary-to-decimal.html

Try the following questions, ignoring the answers until you are ready or need them:

How do I convert decimal to binary?

We have covered how to convert a binary number into a decimal number, but you also need to know how to convert any decimal number to binary.

There are a few methods for this, I will be using a table method in this article, which I find the easiest and least prone to error.

Let us convert the decimal number 312 to a binary representation:

We draw a table to complete this, write the number to be converted to binary in the top leftmost column of your blank table with three headings for the columns from left to right — A, B, and C.

If the number you start with is an even number, write that same number under the B column. Then in the C column, write down the value of A — B. In this case, as the computation is 312–312 you are left with 0, so write that in the C column.

Now divide column B’s value by 2 and place that answer in the next cell of column A, beneath the last number in column A.

Column B (312) divided by 2 is 156. This is also an even number, so write it in the next cell of column B, and in column C write the difference between the new numbers in columns A and B, which is 156–156 = 0.

Again, divide the value in column B by 2 and continue by writing that value in the next space in column A, beneath the last number in column A (156).

Column B’s latest number is 78, which again is even. We compute the difference between column A and B (78–78), writing 0 in column C.

Then repeat this process — divide 78 by 2 and write it in the next space in column A — which is 39.

Now because the number in column A is odd the next part in this process is to deduct 1 from the number in column A (39) and put the answer in column B.

As you can see — we took 1 away from the odd number in column A, placed the answer in column B, and continued by computing the difference between A and B (39–38) which equals 1. We write this 1 in the C column.

This is essentially an algorithm that we continue, the rules are outlined at the end of this process.

We divide 38 by 2, leaving us with 19, which we write in the A column. As 19 is odd, we minus 1 from 19 to give us an even number and write the difference between column A and B in column C (19–18) which equals 1.

I have continued the process down to 2, as the process is obvious by now.

When we get to two, remember that divided 2 by 2 will give you 1. We place 1 as the final row of digits in column A.

Because 1 is an odd number, we take away 1 from 1 leaving us with 0, which is an even number that we place in column B. Then in column C we write the difference between 1 and 0, which is 1.

The final table will look like this now:

Now to get the binary number from this table, we start at the top in the C column (0) and write this down as the Least Significant Digit in our answer.

100111000

Then write down the next digit in the C column beneath the topmost digit, which is another 0.

100111000

Then write down the next digit in the C column beneath the last we looked at, which is another 0.

100111000

The next number in column C is 1, write that next.

100111000

We continue down the table until we reach the final digit, writing the numbers down right to left.

The final digit in the table is a 1 — write that down as the Most Significant Digit.

100111000

Rules for converting decimal to binary with a table method.

1. Write the number we are converting from decimal to binary in the top left-most column — call this column A.

2. If the number is even, write the same number next to it in column B.

3. If the number is odd, deduct 1 from it and write the answer next to it in column B.

4. Write the difference (A — B) value in column C, to the right of the answer you wrote in step 3.

5. Divide column B’s value by 2 and put the answer in the next row of column A, beneath the last number you wrote in column A.

6. Continue this process until the number in column B is 0. You have now finished the conversion.

7. Write each of the numbers in column C (either 0 or 1) from the top of column C going down starting at the least significant digit place. This is your binary number.

To be 100% sure you have the correct answer, convert your binary number back to decimal — consult the chart we looked at earlier for binary to decimal conversion.

The following is an extremely useful quiz tool for testing Decimal/Binary conversion knowledge. I would strongly recommend attempting several quizzes and memorizing the charts provided in this article so that you will be successful in understanding how to Convert Decimal to Binary and Binary to Decimal.

http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/binquiz.html