Binary representation and manipulation
GOOD DAY, students. This is lesson 10 in our series of lessons. In this week’s lesson, I will continue to look at binary representation and manipulation.
FINDING THE ONES COMPLEMENT OF AN INTEGER NUMBER
The one’s complement representation simply involves flipping the bits of a given number. You flip zeros to ones and ones to zeros. Ensure the number is in its positive form, whether four or eight bits, before you find the one’s complement of the number.
Find the one’s complement of - 17 using 8-bits. 17 in binary is 100012 The eight bit representation of 17 would be 00010001
FINDING THE TWOS COMPLEMENT OF AN INTEGER NUMBER
This is another method of representing integers. This enables subtraction to be performed by a modified form of addition, which is easier to execute in the computer. If the number is positive or negative, do the following: Step 1: Write the number in its positive sign and magnitude form. Step 2: Flip the bits (find its one’s complement). Step 3: Add one (1) to the number obtained in step 2. Step 4: The result is the number in its two’s complement notation.
Find the two’s complement of -17.
Step 1: 17 in positive sign and magnitude is 00010001 (if you are not sure how I arrive at this, go back to the previous lesson, where we looked at sign and magnitude)
CONVERTING A TWOS COMPLEMENT INTEGER TO DECIMAL
To carry out this conversion, you would apply the same concept you learnt in lesson 8 on converting binary number into decimal. Let us use the twos complement value of -17 we obtained above to be converted to decimal.
CODING SCHEMES ASSOCIATED WITH DATA REPRESENTATION
The combinations of 0s and 1s used to represent characters are defined by patterns, called a coding scheme. Using one type of coding scheme, the number one (1) is represented as 00110001. Two popular coding schemes are American Standard Code for Information Interchange (ASCII) and Extended Binary Coded Decimal Interchange Code (EBCDIC). ASCII is used mainly on personal computers, while EBCDIC is used primarily on mainframe computers.
Given that the ASCII code for ‘h’ is 1001000, find the ASCII code for the letters ‘j’ and ‘d’. 1. First you determine where ‘j’ falls in the letters of the alphabet from the position of ‘h’. 2. To maintain the same base value, convert the decimal number 2 (the number of spaces from ‘h’ to ‘j’) to binary. Thus, 2 in binary is 102 3. Add the binary equivalent of 2 to the ASCII representation of ‘h’ as shown below.
Finding the ASCII representation of ‘d’.
Here are the answers to the practice questions you were given in the previous lesson on BCD. Did you complete the questions correctly? If you did, keep up the good work. 1. (a) 8978 = 1000100101111000 or 10101000100101111000 (b) -62 = 101101100010 (c) 4560 = 0100010101100000
2. (a) 0001/0101/1000 = 158 (b) 1011/0111/0000/0101 = - 305
We have come to the end of this lesson. See you next week, when we will continue to look at binary representation and manipulation. Remember, if you fail to prepare, you prepare to fail.
Natalee Johnson teaches at Ardenne High School. Send questions and comments to email@example.com