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

ASSIGNMENT # 1

ADDITION, SUBTRACTION

Hassan Danial
SP16-BCS-018
05-OCT-2017
Q 1: Convert the following numbers to hexa-decimal.
(a) 10010101101010111010101010101111b

Sol: 0 x 9 5 A B A A A F

(b) 8997897

Sol:
16 8997897
16 562368 - 9
16 35148 - 0
16 2196 - C
16 137 - 4
8-9

(0x89C09)16

Q 2: Perform the following addition:


(a) 0xB23CDD78+ 0x17921EFD
Sol:
0xB23CDD7 8
+0x1 792 1E FD
0xC9CEFC 7 5
(b) 0xFEFFEEEE + 0xFBCADAAA
Sol:
0xFEF FE EE E
+0xFBCADAAA
0xFACAC9 9 8

Q 3: Perform the following subtraction:

(a) 10000101b – 111011b


Sol:
10000101
-00111011
01001010

(b) 0x5FC12 – 0x3ABD1


Sol:
0x5FC1 2
0x3ABD1
0x25 0 41

Q 4: Give the 16-bit representation of each of the following decimal


integers. Write answer in hex:
(a) -32216
Sol:
16 32216
16 2013 - 8
16 125 - D
7-D

0x7DD8

7 D D 8
0111 1101 1101 1000

1000 0010 0010 1 0 0 0  2’s Compliment

8 2 2 8  2’s Compliment

16-bit = - 0 x 8 2 2 8

(b) 234
Sol:
16 234
E-A

0xEA

E A
1110 1010
0001 0 1 1 0  2’s Compliment
1 6  2’s Compliment
16-bit = - 0 x F F 1 6
Q 5: Do the following binary and hex subtraction by two's
compliment addition:
Sol:
(a) A 10110100b – B 10010111b

10110100
0 1 1 0 1 0 0 1  2’s Compliment of B

00011101

(b) A 0xFE0F0123 – B 0x12AB8796

 2’s Compliment of B

1 2 A B 8 7 9 6
0001 0010 1010 1001 1000 0111 1001 0110

1110 1101 0101 0100 0111 1000 0110 1010  2’s Compliment

E D 5 4 7 8 6 A  2’s Compliment
0xFE0F012 3
0xED54786A

0x

You might also like