Conversion of binary number system

Binary number system is the base of computer system. If you want to know how CPU or microprocessor works, how they allocates memory or computes numbers and other things you must have a vast knowledge on binary number system. This article covers the basic of binary number system.
In this article you will learn –
  • What is binary number?
  • How to convert a number into its equivalent binary number and vice-versa
In upcoming articles, I shall describe you how addition, subtraction, multiplication and division take place in binary number system and for what reason binary numbers are used in computer system.
So let’s start –

What is binary number system?

As the name “binary” suggests, binary number system has only two numbers 0 and 1. Because of the fact that it has only two numbers, the base of the number system is two. It is also called two-based number system. Everything in binary number system is represented by 0 and 1. You cannot write other numbers or characters in a binary number system device. Computers only recognize 1 and 0. When you types a character on a keyboard, computer just convert it to its equivalent binary number. When you give an instruction to a computer, computer converts the instruction into its equivalent machine code and then moves accordingly to the machine code.

1101 ,0100 0111, 1111 1111 1111 − these all are example of binary number.

Conversion of a number system into its equivalent binary number system

We can convert any number system to binary number system and this is easy. Nothing is so complicated that it seems to be. There are total four number systems which are listed below –
  • Decimal number system (0 to 9 )
  • Binary number system (0 and 1)
  • Octal number system (0 to 7)
  • Hexadecimal number system (0 to 9 and A to F)
Let us see how we can convert them to binary numbers.

Decimal − Binary Conversion

Let’s take the decimal number 25.Every digit in the number have a weight. The weight of ‘2’ is 10 times of the weight of ‘5’ –

        (25)₁₀ = 2×10¹ + 5×10⁰

Similar thing works in binary number system. Here, the weight of each successively higher position to the left is an increasing power of two −

         (1101)₂ = 1 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰
                       = 8 + 4 + 0 + 1
                       = (13)₁₀

Thus, binary number 1101 is equivalent to 13 in decimal number system. Here,()₁₀ or ()₂ are used only to say that 13 is a decimal number(base is 10) and 1101 is a binary number( base is 2). There is no extra meaning.
What about float values? For example, suppose we have to convert a binary number 1101.1101 into its decimal equivalent. How do we do that?
This is simple! We can obtain the result by following the same procedure. In decimal number system the number 25.556 is same as 2 × 10¹ + 5 × 10⁰ + 5 × 10⁻¹ + 5 ×10⁻² + 6 ×10⁻³.

Observing the above example, we can write –
       (1101.1101)₂ = 1 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰ + 1 × 2⁻¹ + 1 ×2⁻² + 0 ×2⁻³ + 1 ×2⁻⁴
                                  = 8 + 4 + 0 + 1 + 0.5 +0.25 + 0.125 + 0.0625
                                  = (13.9375)₁₀
Now we can convert a binary number to its equivalent decimal number. But how can we convert decimal into binary? Here is the answer –
  • Divide the decimal number by 2 progressively, until the quotient of 0 obtained
  • Take the remainder after each division in the reverse order.
  • Tada! You have got your answer!

Example: convert the decimal number 13 into its equivalent binary number
Step 1: divide the number by 2 progressively, until the quotient of 0 obtained and take each remainder

Step 2: read the remainders from bottom to top. Thus, we find that the answer is (1101)₂.

Fractional conversion

To get the fractional part of a decimal number as a binary number fraction, we have to multiply the fractional part continuously by 2 until the result become zero and record a carry in the integer position each time. The carries in the forward order gives the required binary number.
Example: Convert 0.25 into its binary equivalent

So, the binary equivalent to the fraction part is (0.010)₂.
Note: Here you have to move in the forward order.
One may be jealous of you and can ask you to convert a decimal number whose integer part is not zero (such as 13.25,459.456 etc) to check your cleverness. Do not get nervous. Just break that number into two pieces --- integer part and fractional part and convert each part separately.
For example, if you want to convert 13.25 into binary, then break them into integer part which is 13 and fractional part which is 0.25.Then convert 13 into its binary equivalent and convert 0.25 into its binary equivalent. After that, simply add them. 

Octal-Binary Conversion

You have learned how to convert decimal to binary or binary to decimal just now. Octal-binary conversion is much simpler.
To convert binary into octal, start to look from the least significant bit of the given binary number and then form groups of 3 bits. Then replace each group of 3 bits with its equivalent decimal number.
For example, Equivalent of binary number 1101 0010 1111 will be –

(1101 0010 1111)₂ = (110 100 101 111)₂
                               =    6      4      5      7
                               =    (6457)₈
To convert octal into its equivalent binary, replace each digit in the given number with its 3-bit binary equivalent. For example –
                 (577)₈ =      5        7        7
                             =   101    111    111
                             = (101111111)₂
For obtaining binary equivalent of fractional part follow the same procedure.

Hexadecimal-Binary Conversion

It is similar to Octal-binary conversion. In this case, you have to form 4-bit group of binary number for each equivalent hexadecimal number.
For example –
                (5DA)₁₆ =        5           D           A
                              =   0101      1101     1010
                              = (010111011010)₂
And
               (11110110101)₂ = 0111   1011   0101
                                         =  7            B         5
                                         = (7B5)₁₆
I hope you understand the above mentioned topics .If you have any confusion please reread the article. If you still do not understand, comment below. I will try to solve your problem. One thing, can you say why I replaced the octal number or hexadecimal number with its 3-bit equivalent or 4-bit equivalent respectively? Comment below. I shall answer this question in my next article.


Comments

Popular Posts