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

1. Explain using an example (use 4-bit 1010) how a 2’s compliment number can be

ID: 3900757 • Letter: 1

Question

1.       Explain using an example (use 4-bit 1010) how a 2’s compliment number can be represented in usual positional number representation- except the weight of the MSB will be negative.

2.       Indicate how the following +ve numbers will be represented in (a) Two’s compliment (b) two’s complement (c) BCD (d) Two’s compliment and (e) Excess-7 representations? [or state ‘not possible’]

0 , 1,   6,    8

3.       Indicate how the following –ve numbers will be represented in (a) Two’s compliment (b) two’s complement and (c) Excess-7 representations? [or state ‘not possible’]

-1, -5, - 8, -9

4.       Discuss how an overflow can be detected in two’s complement systems.

                Is there any relationship between overflow, and carry-in to MSB and carry-out from MSB?

5.       Assume a compiler represent very small integers (say vsint) as 4-bit (nibble) 2’s complement numbers.

a.       What is the range of vsint?

Suppose variables W, X, Y, and Z are initialized as follows (type vsint).

vsint W = -1, X = 3, Y = 6, Z = -6

b.      How X, Y and Z will be represented?

c.       Show how the following operations will be calculated by a 4-bit ALU?

X + X,     X + Y,   X + Z, W + Z, Z + Z, X – Y,   Y – X, Z – X , X – Z and W – Z

d.      Which of the above operations will overflow?

e.      Show how X*Y and X*Z will be calculated (assume intermediate calculations will be done in 8-bit register). Write an algorithm to demonstrate this operation.

f.        Show how Y/X and Z/X will be calculated.

Explanation / Answer

1) Starting from LSB,multiply each bit with 2i where i=0 and increment i by 1 as we move towards MSB.

That is consider a 4 bit binary number a1a2a3a4 On number line,it will be represented as a4*20 + a3*21 + a2*22 + a1*23

2)

a) 1's compliment of binary means changing the bit 1 to 0 and 0 to 1

2's compliment of binary = 1's compliment + 1

Consider that each number to be represented in 4 bits -

0 in binary will be 0000.Its 1's compliment is 1111 and 2's compliment is 1111 + 1 Its result is 10000 and the overflow that is bit 1 from MSB will be ignored .Hence 2's compliment of 0 is 0000

1 in binary will be 0001.Its 1's compliment is 1110 and 2's compliment is 1110 + 1 = 1111

6 in binary will be 0110.Its 1's compliment is 1001 and 2's compliment is 1001 + 1 = 1010

8 in binary will be 1000.Its 1's compliment is 0111 and 2's compliment is 0111 + 1 = 1000

b) Part b is same as part a)

c) In BCD, each decimal digit is represented in 4 bit binary

BCD of 0 = (0000)BCD

BCD of 1 = (0001)BCD

BCD of 6 = (0110)BCD

BCD of 8 = (1000)BCD

d) Part d) is same as part a)

e) In decimal to excess 7 representation,add 7 to each number and then convert this in binary.

Excess 7 of 0 - 0+7 = 7 Its excess 7 representation is 0111

Excess 7 of 1 - 1+7 = 8 Its excess 7 representation is 1000

Excess 7 of 6 - 6+7 = 13 Its excess 7 representation is 1101

Excess 7 of 8 - 8+7 = 15 Its excess 7 representation is 1111

I will add answers of remaining questions very soon.

Hope i have answered your question satisfactorily.Leave doubts in comment section if any.