In this article, we will learn Binary Numbers by comparing them with Decimal Numbers. We will also learn to convert Decimal Numbers to Binary Numbers, and convert Binary Numbers to Decimal Numbers.

We all have learned our decimal number system in elementary school mathematics. But what about electronic devices? Do they know it too? The answer is no!

All electronic components and devices, use electronic pulses, called Bit signals. On or Off. ‘Off’ is Zero (0), and ‘On’ is One (1).

To make it simple and easier, let us compare it with our good old decimal number system. As we all know Decimal Numbers are a composition of Deca numbers, which are Ten base numbers. This number system has only ten numbers, which are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Using only these ten numbers, all other Decimal Numbers are formed.

But if number 9 is the largest single-digit decimal number, how do we get the next number? We are out of digits here. Hence as per the number system, we create the next number by increasing the left-most digit by one and resetting the 9 to 0. So, since 9 is the largest digit, the left-most digit of 9 is 0. Increasing the 0 by 1 is 1, and resetting the 9 to 0, we get the next number to 9 as 10.

Similarly, the next number to 19 is 20, the next number to 109 is 110 and the next number to 999 is 1000 and it continues to infinity.

Likewise, the binary number system, which is a base two number system, as mentioned earlier has only two digits, 0 & 1 and all numbers of the Binary System must be formed using only these two numbers. So, if the largest single-digit number, in the binary number system is 1, then what would be the next number? Simply, increase the left most by one and reset the largest number to Zero. So, the next number to 1 would be 10, as there are no more digits in the binary number system.

Therefore, the Binary Numbers go like this:

0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011… and so on.

Mathematically these numbers as “*Number System*” are represented with their base numbers like 10 for decimal and 2 for binary number system.

(NUMBER)_{BASE}

So, the number 5 in the decimal number system, is written as (5)_{10}, and the same number in binary will be written as (101)2. Note that even if these two numbers look different, in terms of “*value*”, these two numbers are the same, and hence, we write:

(5)_{10} = (101)_{2}

Now we know and can figure out some of the first few Binary Numbers. But what about the larger ones? Say binary equivalent of decimal number 256?

To do so we need to do simple & elementary mathematics.

DividetheDecimal Numberwith theBase Numberof which we want to convert to, and collect theRemainder, fromBottomtoTop.

We are converting “to Binary”, so our base number should be 2. Now let us rewrite the above statement.

Divide the Decimal Number with 2, and collect the Remainder, from Bottom to Top.

So, as we know, if we are dividing a number, the remainder is always lesser than the divisor. So if we are dividing a number by 2, our remainders will always be 0 or 1, as they are the only two numbers lesser than 2.

Here are two examples of Decimal Numbers converted to Binary Numbers.

Now try some of your own.

- (67)
_{10 }= (?)_{2 } - (14)
_{10 }= (?)_{2 } - (55)
_{10 }= (?)_{2 } - (413)
_{10 }= (?)_{2}

If there is a way to convert decimals to binary, there should be a way to convert binary to decimals also… right? Yes. Let us see how.

To convert a binary number to a decimal number again we have to perform a simple mathematical procedure.

Multiplyevery digit by theBase Numberfromwhich we are converting,raisedto thePowerof itsPlace Position, starting asZerofromRighttoLeft, andSum up.

So since we are converting from binary, again our base number is 2. So, let us rewrite the above statement.

Multiply every digit by 2, raised to the Power of its Place Position, starting as Zero from Right to Left, and sum up.

Before we go to examples, let us recap the following mathematical facts:

Any number (N),

- raised to the Power of Zero, is One. N
^{0}= 1 - to the power of One, is the number itself. N
^{1}= N - multiplied by Zero, is Zero. Nx0 = 0
- multiplied by One, is the number itself. Nx1 = N

Now try some of your own.

- (1101)
_{2}= (?)_{10} - (10011)
_{2}= (?)_{10} - (11001)
_{2}= (?)_{10}

Practice a few and once you are comfortable converting decimal to binary, and binary to decimal. Once done, you are ready to learn the Magic Trick, using the binary number system, coming up next. But, before that make sure you have read my earlier article on Fundamentals of Programming.