Ass No 3
Ass No 3
Problem # 10.1:
Represent the following decimal numbers in both binary sign/magnitude and twos
complement using 16 bits: + 512; - 29.
Solution:
512 0000 0010 0000 0000
Sign Magnitude
-29 0000 0010 0000 0000
512 1000 0000 0001 1101
Two’s Complement
-29 1111 1111 1110 0011
Problem # 10.2:
Represent the following twos complement values in decimal: 1101011; 0101101
Solution:
1101011: This is a negative number as it starts with 1 in the left, its magnitude
can be calculated by flipping the bits and adding 1.
0010100 + 1 = 0010101
Answer= -21 (where negative sign shows that number is started from
leftmost 1).
0101101: This is a positive number as it starts with 0 in the left, and its
magnitude can simply be calculated and we get,
Answer=45
Problem # 10.10:
Assume numbers are represented in 8-bit twos complement representation. Show
the calculation of the following:
a. 6 + 13
b. -6 + 13
c. 6 – 13
d. -6 – 13
Solution:
a. 6+13 = 00000110 + 00001101 = 00011011
b. -6+13 = 11111010 + 00001101 = (1)00000111
c. 6-13 = 00000110 + 11110011 = 11111001
d. -6-13 = 11111010 + 11110011 = (1)11101101
Problem # 10.11:
Find the following differences using twos complement arithmetic:
a. 111000 – 110011
b. 11001100 -101110
c. 111100001111 – 110011110011
d. 11000011 – 11101000
Solution:
a. 111000
-110011
111000
+001101
= (1)000101
b. 11001100
- 101110
11001100
+ 010010
=11011110
c. 111100001111
-110011110011
111100001111
+ 001100001101
= (1)001000011100
d. 11000011
-11101000
11000011
+ 00011000
= 11011011
Problem # 10.14:
Given x = 0101 and y = 1010 in twos complement notation (i.e.,
x = 5, y = -6),
compute the product p = x * y with Booth’s algorithm.
Solution:
A Q Q-1 M
Problem # 10.23:
Express the following numbers in IEEE 32-bit floating-point format:
a. -5
b. -6
c. -1.5
d. 384
e. 1/16
f. -1/32
Solution:
a. -5
5 = 101 = 1.01 x 22
exponent = 127 + 2 = 129 = 10000001
1 10000001 01000000000000000000000
b. -6
6 = 110 = 1.10 x 22
exponent = 127 + 2 = 129 = 10000001
1 10000001 10000000000000000000000
c. -1.5
1.5 = 1.1 = 1.1 x 20
exponent = 127 = 01111111
1 01111111 10000000000000000000000
d. 384
384 = 384-256 = 128 -128 = 0; = 110000000 = 1.1 x 28
exponent = 8 + 127 = 135 = 10000111
0 10000111 10000000000000000000000
e. 1/16
1/16 = .0001 = 1.0 x 2-4
exponent = 127 – 4 = 123 = 01111011
0 01111011 00000000000000000000000
f. -1/32
1/32 = .00001 = 1.0 x 2-5
exponent = 127 – 5 = 122 = 01111010
1 01111010 00000000000000000000000
Problem # 10.24:
The following numbers use the IEEE 32-bit floating-point
format. What is the equivalent decimal value?
a. 1 10000011 11000000000000000000000
b. 0 01111110 10100000000000000000000
c. 0 10000000 00000000000000000000000
Solution:
a. 1 10000011 11000000000000000000000
sign = -
exponent = 131 – 127 = 4
1.11 x 24 = 11100 = 28
Answer=-28 (Negative sign is due to the leftmost 1 in the value which
shows the value is negative)
b. 0 01111110 10100000000000000000000
sign = +
exponent = 126 – 127 = -1
1.101 x 2-1 = .1101 = ½ + ¼ + 1/16 = .8125
Answer=.8125
c. 0 10000000 00000000000000000000000
sign = +
exponent = 128 – 127 = 1
1.0 x 21 = 10 = 2
Answer=2