Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In class, we have been introduced to the Two\'s Complement approach to represent

ID: 3590631 • Letter: I

Question

In class, we have been introduced to the Two's Complement approach to representing signed integers. As a possible alternative, the One's Complement approach computes the bitwise logical complement of an unsigned binary integer in order to represent a negative integer. For example, (5)n° (0101)2 (5)n° (1010)2. a. Using the one's complement representation, for m 5 bits, construct a table showing all possible binary numbers. Also, in your table, for each binary sequence listed, show the corresponding value in base 10. b. In general, given 'm' bits, what are the maximum and minimum values allowable in this representation? Provide your answer in both base 10 and base 2. c. By providing three examples of your choice, perform the binary addition of three pairs of numbers d. Based upon the examples you constructed in part (b), discuss any potential difficulties with using the one's complement representation e. Johnny Notaverygoodcomputerperson decides to build a computer system based upon the one's complement representation. Meanwhile, everyone else in the known Universe applies the two's complement representation. Assume that Johnny's computer communicates integer data to another computer system i. Explain what Johnny must do in order to convert the one's complement data to two's complement data mbers, provide three examples demonstrating a system of steps that will perform the conversion. Assume that a computer system communicates integer data to Johnny's computer f. i. Explain what Johnny must do in order to convert the incoming two's complement data to one's complement data. provide three examples demonstrating a system of steps that will perform the conversion.

Explanation / Answer

a)

b)

MAX and MIN in Base 10 would be :

MAX : 2m-1 - 1

MIN : - ( 2m-1 - 1)

e.g : going by m = 5 bits which is represented in answer (a)

MAX value : 24 - 1 = 15

MIN value : - (24 -1 ) = -15

MAX and MIN value in Base 2

MAX value : ( 0 1 1 1 ....... ) upto m bits

i.e incase of max value the first bit is zero and rest are '1'

MIN value : ( 1 1 1 1 1 ...... 0)

i.e all bits are '1' except the last bit

c)

Here we are going to consider three cases and lets assume we are using 5 bit representation :

i) Adding positve number to positive

4 + 5

00100

+ 00101

-----------

01001 ( +9)

-----------

ii) Positive to negative number but the positive value is more

5 & -3

00101

+ 11100

-------------

100001

since we are using only 5 bits representation we are going to ignore the left most bit. so the value of addition is (00001) which is (+1).

iii) positive with negative number but negative number is more

5 & -6

00101

+ 11001

---------------

11110

----------------

since the leftmost bit is '1' this means it's a negative number in 1's complement. Now we will flip all the bits to get whose negative it is . So the answer is negative of (00001) i.e. (-1)

d) One of the problems with using 1's complement method is that we have two representation for number "0". If we look at the example solved in answer (a). both (00000) and (11111) represent the same number .. (11111) represents -(0) which is actually zero. This can create confusions and also a waste of representation.

e)

i)

If the number is positive (i.e. the left most bit in the binary representation is "0") then Johnny can directly send the data as the 2's complement representation remains the same.

If the leftmost bit in the binary representation is "1" then it's a negative number and Johnny needs to add "1" to the one's complement value.

ii) Let's assume 5 bit number

if number is positive (+5)

1's complement representation : 00101

2's complement representation : 00101

if number is positive (-5)

1's complement representation : 11010

2's complement representation  : (11010) + 1 = (11010) + ( 00001) = 11011

if number is (-8)

1's complement representation : 10111

2's complement representation : 10111 + 1 = 10111 + 00001 = 11000

f)

i)   If the number is positive (i.e. the left most bit in the binary representation is "0") then Johnny can directly use it as the data in 2's complement and 1's complement representation remains the same.

if the leftmost bit is "1" then it's a negative number. In that case Johnny has to add (-1) to that number to get 1's complement but (-1) has to be in 2's complement, which is (11111) in 5 bit representation.

ii)

If the number is positive (+5) the no conversion is required.

If the number is negative suppose (-8) which in two's complement is (11000) then we need to add (11111) to it .

11000

+ 11111

---------------

110111

Since we are using only 5 bit for representation value is (10111) which is (-8) in 1's complement.

if the value is zero -1, then 2's complement representation is (11111) adding (11111) we get (11110) which is 1's complement representation of (-1).

Binary representation Unsigned value(base 10) One's complement value 00000 0 0 00001 1 1 00010 2 2 00011 3 3 00100 4 4 00101 5 5 00110 6 6 00111 7 7 01000 8 8 01001 9 9 01010 10 10 01011 11 11 01100 12 12 01101 13 13 01110 14 14 01111 15 15 10000 16 -15 10001 17 -14 10010 18 -13 10011 19 -12 10100 20 -11 10101 21 -10 10110 22 -9 10111 23 -8 11000 24 -7 11001 25 -6 11010 26 -5 11011 27 -4 11100 28 -3 11101 29 -2 11110 30 -1 11111 31 -0
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote