# Bi­nary rep­re­sen­ta­tion and ma­nip­u­la­tion

Jamaica Gleaner - - YL: FEATURE - NATALEE A. JOHNSON Con­trib­u­tor

GOOD DAY, stu­dents. This is les­son 10 in our se­ries of lessons. In this week’s les­son, I will con­tinue to look at bi­nary rep­re­sen­ta­tion and ma­nip­u­la­tion.

FIND­ING THE ONES COM­PLE­MENT OF AN INTEGER NUM­BER

The one’s com­ple­ment rep­re­sen­ta­tion sim­ply in­volves flip­ping the bits of a given num­ber. You flip ze­ros to ones and ones to ze­ros. En­sure the num­ber is in its pos­i­tive form, whether four or eight bits, be­fore you find the one’s com­ple­ment of the num­ber.

EX­AM­PLE 1

Find the one’s com­ple­ment of - 17 us­ing 8-bits. 17 in bi­nary is 100012 The eight bit rep­re­sen­ta­tion of 17 would be 00010001

FIND­ING THE TWOS COM­PLE­MENT OF AN INTEGER NUM­BER

This is an­other method of rep­re­sent­ing in­te­gers. This en­ables sub­trac­tion to be per­formed by a mod­i­fied form of ad­di­tion, which is eas­ier to ex­e­cute in the com­puter. If the num­ber is pos­i­tive or neg­a­tive, do the fol­low­ing: Step 1: Write the num­ber in its pos­i­tive sign and mag­ni­tude form. Step 2: Flip the bits (find its one’s com­ple­ment). Step 3: Add one (1) to the num­ber ob­tained in step 2. Step 4: The result is the num­ber in its two’s com­ple­ment no­ta­tion.

EX­AM­PLE 2

Find the two’s com­ple­ment of -17.

Step 1: 17 in pos­i­tive sign and mag­ni­tude is 00010001 (if you are not sure how I ar­rive at this, go back to the pre­vi­ous les­son, where we looked at sign and mag­ni­tude)

CON­VERT­ING A TWOS COM­PLE­MENT INTEGER TO DECIMAL

To carry out this con­ver­sion, you would ap­ply the same con­cept you learnt in les­son 8 on con­vert­ing bi­nary num­ber into decimal. Let us use the twos com­ple­ment value of -17 we ob­tained above to be con­verted to decimal.

CODING SCHEMES AS­SO­CI­ATED WITH DATA REP­RE­SEN­TA­TION

The com­bi­na­tions of 0s and 1s used to rep­re­sent char­ac­ters are de­fined by pat­terns, called a coding scheme. Us­ing one type of coding scheme, the num­ber one (1) is rep­re­sented as 00110001. Two pop­u­lar coding schemes are Amer­i­can Stan­dard Code for In­for­ma­tion In­ter­change (ASCII) and Ex­tended Bi­nary Coded Decimal In­ter­change Code (EBCDIC). ASCII is used mainly on per­sonal com­put­ers, while EBCDIC is used pri­mar­ily on main­frame com­put­ers.

EX­AM­PLE 1

Given that the ASCII code for ‘h’ is 1001000, find the ASCII code for the let­ters ‘j’ and ‘d’. 1. First you de­ter­mine where ‘j’ falls in the let­ters of the al­pha­bet from the po­si­tion of ‘h’. 2. To main­tain the same base value, con­vert the decimal num­ber 2 (the num­ber of spa­ces from ‘h’ to ‘j’) to bi­nary. Thus, 2 in bi­nary is 102 3. Add the bi­nary equiv­a­lent of 2 to the ASCII rep­re­sen­ta­tion of ‘h’ as shown below.

EX­AM­PLE 2

Find­ing the ASCII rep­re­sen­ta­tion of ‘d’.

Here are the an­swers to the prac­tice ques­tions you were given in the pre­vi­ous les­son on BCD. Did you com­plete the ques­tions cor­rectly? 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 les­son. See you next week, when we will con­tinue to look at bi­nary rep­re­sen­ta­tion and ma­nip­u­la­tion. Re­mem­ber, if you fail to pre­pare, you pre­pare to fail.

Natalee Johnson teaches at Ar­denne High School. Send ques­tions and com­ments to kerry-ann.hep­burn@glean­erjm.com