In: Computer Science
1. Obtain the 1’s complement, 2’s complement and sign magnitude system representation in 7 bits for the following decimal numbers:
a) 1510
b) -2110
c) 3510
d) -2710
2. Use 1’s and 2’s complement system to perform the following
calculations and mention if
there will be overflow or not:
a) 1100 – 0101
b) 1010 + 0100
c) 01100 + 00111
a) 15 Since this is a positive number. we can directly convert this into binary Step 1. Divide 15 successively by 2 until the quotient is 0 15/2 = 7, remainder is 1 7/2 = 3, remainder is 1 3/2 = 1, remainder is 1 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 1111 1's complement: 0001111 2's complement: 0001111 sign-magnitude: 0001111 b) -21 This is negative. so, follow these steps to convert this into a 2's complement binary Step 1. Divide 21 successively by 2 until the quotient is 0 21/2 = 10, remainder is 1 10/2 = 5, remainder is 0 5/2 = 2, remainder is 1 2/2 = 1, remainder is 0 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10101 So, 21 in normal binary is 0010101 1's complement: ------------------- flip all the bits 0010101 is flipped to 1101010 1's complement: 1101010 2's complement: ------------------- Add 1 to above result 1101010 + 1 = 1101011 2's complement: 1101011 sign-magnitude: ----------------- set 1 as left most bit so, 0010101 is 1010101 sign-magnitude: 1010101 c) 35 Since this is a positive number. we can directly convert this into binary Step 1. Divide 35 successively by 2 until the quotient is 0 35/2 = 17, remainder is 1 17/2 = 8, remainder is 1 8/2 = 4, remainder is 0 4/2 = 2, remainder is 0 2/2 = 1, remainder is 0 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 100011 1's complement: 0100011 2's complement: 0100011 sign-magnitude: 0100011 d) This is negative. so, follow these steps to convert this into a 2's complement binary Step 1: Step 1. Divide 27 successively by 2 until the quotient is 0 27/2 = 13, remainder is 1 13/2 = 6, remainder is 1 6/2 = 3, remainder is 0 3/2 = 1, remainder is 1 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 11011 So, 27 in normal binary is 0011011 1's complement: ------------------- flip all the bits 0011011 is flipped to 1100100 1's complement: 1100100 2's complement: ------------------- Add 1 to above result 1100100 + 1 = 1100101 2's complement: 1100101 sign-magnitude: ----------------- set 1 as left most bit so, 0011011 is 1011011 sign-magnitude: 1011011