Warning: Use of undefined constant viewed_cookie_policy - assumed 'viewed_cookie_policy' (this will throw an Error in a future version of PHP) in /home/customer/www/hyperelectronic.net/public_html/wp-content/themes/customizr-child/functions.php on line 99
Cookie named 'viewed_cookie_policy' is not set!
When working with binary number, you will often have to convert decimal number to binary number. If you remember in the Chapter 3 about logic gates, we had a truth table to list all possibles inputs combinations of a combinational logic circuit. The truth table was a list of all possible inputs combinations and it was using the binary system starting from zero to the numbers of possible inputs combination. With 4 binary inputs, we had 16 possibilities. To find the number of possibles combinations for this type of circuits, you take 2 exponent the numbers of inputs.
From last lesson, we have the following figure for the place value of each digits :
Just with Figure 1, it is possible to convert the truth table of Chapter 3 to decimal. Below, you can find a table that show each binary number of the 4 inputs truth table converted to decimal :
For the decimal number 7, we need the first position digit (has a value of 1), the second position digit (has a value of 2) and third position digit (has a value of 4) :
The decimal number 7 in binary is shown below. You can exclude the left most zero if you want since it is implied that it is zero. The same principles is applied in the decimal numbering system since you wouldn’t write the number thirteen like this (013) but like this (13).
So far, we have converted small decimal number to binary number using Figure 1 and some mathematics as shown in the example above. This is possible when working with small number but it gets a bit more complicated with bigger numbers.
Decimal to binary :
In our example, we want to represent the decimal number 33 in the binary numbering system. There is two methods available to convert a decimal number to the binary system. The first method is called the sum of weights and the second method is called the repeated division by 2. The repeated division by 2 is generally prefer for bigger number.
Sum of weights
With four digits like on Figure 1, we can’t represent the decimal number 33 since the biggest decimal number we can have in the binary numbering system with four digits is 15 (8+4+2+1). We need more digits to represent the decimal number 33 in the binary numbering system. Finding the weight value of the next digit is simple. You multiply by 2 the decimal weight value to its right. We need to know the weight value of each digit and figure out which digits needs to be 1s to have a decimal value of 33. Below, you can find the weights value of the first 7 digits of the binary numbering system.
Now that we know the weight value of the first 7 digits of the binary numeral system, we can find the binary number of the decimal number 33. We need the digit that weights 32 and 1 to get 33 (32 + 1 = 33). This the first digit and sixth digit starting from the right. These digits needs to be 1s.
A second example : we want to find the binary number of the decimal number 25. To get the decimal number 25, we need to add the weights 16, 8 and 1. 16 + 8 + 1 = 25. We need the first, fourth and fifth digits to represent the decimal number 25. These digits needs to be 1s.
This method has some limitations. It can get complex when you need to add multiples digits together to find a number. The second method below is easier for big decimal number that are more difficult to calculate with this method.
Repeated division by 2
Again, we want to represent the decimal number 33 in the binary numeral system but this time using the repeated division by 2. The repeated division by 2 is generally prefer for bigger integer number. For the decimal number 33, we start by dividing by 2. The remainder from each division forms the binary number. We divide by 2 until we get 0. The remainder of the first division is the first digit of the binary number or the right most digit (often called the least significative bit LSB). The remainder of the last division is the left most digit (often called the most significative bit MSB).
A second example, we want to represent the decimal number 27 in the binary numeral system using the repeated division by 2. We start by dividing by 2. The remainder from each division forms the binary number. We divide by 2 until we get 0.
You have completed this lesson, you can now convert decimal integer number to the binary numbering system using two different methods (Sum of weights and Repeated division by 2). You can use either methods to convert a decimal number. In general, the repeated division by 2 is easier but longer. In the next lesson, we will see how to convert binary numbers to the decimal numbering system. We will also have examples just like this lesson.