Assignment 1 ECS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Assignment 1

Part – A

1. Illustrate subtraction using ones and twos complement:

i. Ones complement:

Let us take R=8-4

A=8 B=4

4 bit of B = 0100

1’s complement = 1011 (Find ones complement of B)

1000

1011

10011 R=R+1(Carry obtained after addition, add to R)

=0100 ( 4 )

ii. Twos complement:

Let us take R=6-4

A=6 B=4

4 bit of B = 0100

2’s complement of B = 1100

0110

1100

10010 (Ignore carry)

= 0010( 2 )

2. When does overflow occur? Illustrate with examples (4-bit)

=> When the sign of 2 numbers are different, adding them will never result in a overflow.

But when the sign of 2 numbers is same or the sign of the sum is different than the sign of either
numbers overflow occurs.

Eg:

1010(-6)
1100(-4)

0110---- MSB is 0(+ve)

Answer is -10 but MSB rabge is +7 to -8

3. Perform BCD Addition of the following decimals. Also indicate how many BCD corrections
are required in (a) and (b):
(a) 49 and 57

0100 1001

0101 0111

=1001 10110 (Carry 1)

=1010 0110

0110 (Correction step)

=10000 0110 ( 106 )

 1 BCD Correction

(b) 176 and 824

0001 0111 0110

1000 0010 0100

=1001 1001 1010

0110 (Correction step)

= 1001 1001 10000 (Carry 1)

= 1001 1001 0000

0110 (Correction step)

= 1001 10000 0000 (Carry 1)

= 1001 0000 0000

0110 (Correction step)

= 10000 0000 0000

= 0000 0000 0000 (Carry 1)

= 10 0 0

= 1000
 3 BCD Corrections

4. Find the gray code equivalent for the 4-bit binary numbers. How we obtain the gray code
representation for (m+1) bits from m-bits:

 It is a binary code where the successive codes differ in 1-bit.

Gray Code equivalent for 4-bit Binary numbers

We can obtain the gray code representation for (m+1) bits from m-bits by adding a 0 in front of each
code word in m-bit gray code and adding a 1 in front of each code word in the complement of the m-
bit gray code.
Part – B

1. 1011012 to Decimal

= 1x2^0 + 0x2^1 + 1x2^2 + 1X2^3 + 0x2^4 + 1x2^5

= 1 + 0 + 4 + 8 + 0 + 32

= 45

2. 1001.01012 to Decimal

= 1x2^0 + 0x2^1 + 0x2^2 + 1x2^3 + 1x2^-4 + 0x2^-3 + 1x2^-2 + 0x10^-1

= 9.3125

3. 25510 to Binary

255/2 127+1

127/2 63+1

63/2 31+1

31/2 15+1

15/2 7+1

7/2 3+1

3/2 1+1

1/2 0+1

= 11111111

4. 2378 to Decimal

= 7x8^0 + 3x8^1 + 2x8^2

= 7 + 24 +128

= 159

5. 27.12510 to Octal

27/8 3+3

3/8 0+3
=33

0.125 x 8 = 1+0

= 0.1

= 33.1

6. BEED to Decimal

B=11 E=14 D=13

= 13x16^0 + 14x16^1 + 14x16^2 + 11x16^3

= 13 + 224 + 3584 + 45056

= 48877

7. 10101101 to 1’s Complement

= 01010010

8. -1 to 2’s Complement

For -1,

+1 = 0001

-1 = complement of +1 = 1000 + 1 = 1111

= 1111

You might also like