Binary representation (Conversions) G
OOD DAY, students. This is lesson nine of our series of lessons. In this week’s lesson, we will be looking at binary representation and manipulation. At the end of this lesson, you will learn how to: convert a binary number to decimal, convert a decimal number to binary, and subtract and add binary numbers.
Computers store and manipulate data numerically using the binary system (referred to as the machine language), which comprises 1s or 0s and, of course, we will be working with base 2 in our calculations.
CONVERTING DECIMAL NUMBERS TO THEIR BINARY EQUIVALENT
To convert decimal numbers to binary, you are simply going to be dividing the number by 2 and subsequently making a note of the remainder. You will stop dividing when you arrive at a zero. The binary answer is written from the bottom up. Let us now look at an example.
CONVERTING BINARY NUMBERS TO THEIR DECIMAL EQUIVALENT
When converting binary numbers to decimal, for each of the binary digits (bits) you are going to have base 2 raised from 0 to the corresponding number of bits you have. So, if you have four bits, then base 2 will be raised from 0 to 3, example, 20 - 23. Then the value you get when two is raised to the corresponding number is multiplied by its corresponding bit, starting from right to left. You then add the corresponding decimal numbers together to get the decimal equivalent of 100012. Let us now look at an example. I am going to use the answer we obtained from example one. Convert 10012 to its decimal equivalent (This way you can tell if the answer we obtained in example one is correct). Binary Addition
EXAMPLE 2
After multiplication, you would arrive at these values. 16 + 0+ 0 + 0+1 = 17 Therefore 100012 = 1710
BINARY ADDITION
When adding numbers in binary, there are five rules you should apply: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 (This is the binary equivalent of 2, which is read as ‘one zero’ and not ten)
1 + 1 + 1 = 11 (This is the binary equivalent of 3, which is read as ‘one one’ and not eleven) Add the binary numbers 11012 and 11112
SUBTRACTING IN BINARY
When subtracting numbers in binary, there are four rules you should apply: 1- 0 = 1 1 - 1 = 0 0 - 0 = 0 0 - 1 = 1 Please ensure that you include base 2 in your answers as shown above. We have come to the end of this lesson. See you next week. Remember, if you fail to prepare, you prepare to fail.