Chapter 2 Exercise and Answer Sign
Chapter 2 Exercise and Answer Sign
pter
2
Exercise and Answer
Q1. Represent the following decimal numbers in both binary sign/magnitude and twos complement
using 16 bits: +512; -29.
Ans:
Sign Magnitude: 512 = 0000 0010 0000 0000
–29 = 1000 0000 0001 1101
Two’s Complement: 512 = 0000 0010 0000 0000
–29 = 1111 1111 1110 0011
Q2. Represent the following twos complement values in decimal: 1101011; 0101101.
Ans:
1101011: Because this starts with a leftmost 1, it is a negative number. The magnitude of the negative
number is determined by first completement the bits and adding 1: 0010100 + 1 = 0010101
This is 21, so the original value was –21.
0101101: Because this starts with a leftmost 0, it is a positive number and we just compute the
magnitude as an unsigned binary number, which is 45. (25+23+22+20)
Q3. 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
Ans:
Page 1 of 10
Multiplication of Unsigned number
Page 2 of 10
Q4. Given x = 0101, y = 1010 and in twos complement notation (i.e., x=5, y=-6), compute the product
p= x ×y with Booth’s algorithm.
The result of the product of x and y is in A and Q register. In A and Q register, the most significant bit
is 1 so the result is negative number. The magnitude of result is obtained by using two complement
notations.
AQ=11100010=000111012+1=000111102=24+23+22+21=-30
Page 3 of 10
Q5: Use the Booth algorithm to multiply 19 (multiplicand) by 23 (multiplier), where each number is
represented using 6 bits.
Ans:
Using M(multiplicand) =1910=0100112 and Q(multiplier)=2310 =0101112 -M
(2nd complement of M) =101100+1=1011012
Q6: Use the Booth algorithm to multiply 23 (multiplicand) by 29 (multiplier), where each number is
represented using 6 bits.
Ans:
Using M (multiplicand)=2310=0101112 and Q(multiplier)=2910=0111012 -M=101000+1=1010012
Q7: 7 Divide by 3 in binary restoring twos complement notation, using 4-bit words.
Ans:
The divisor is placed in the M register, the dividend in the Q register. So, 7/3 (7 is dividend and 3 is
divisor)
Q=710=01112 M=310=00112
Page 4 of 10
-M(2nd complement of M)=1100+1=11012
A Q M Count Operation
0000 0111 0011 4 Initial
0000 1110 0011 Shift
1101 0011 A←A-M
0000 1110 0011 3 Restore, Q0=0
0001 1100 0011 Shift
1110 0011 A←A-M
0001 1100 0011 2 Restore, Q0=0
0011 1000 0011 Shift
0000 1000 0011 A←A-M
0000 1001 0011 1 Q0=1
0001 0010 0011 Shift
1110 0010 0011 A←A-M
0001 0010 0011 0 Restore, Q0=0
The division result is in A and Q registers. Quotient is in Q and Remainder in A.
Quotient=Q=00102=210
Remainder=A=00012=110
Page 5 of 10
Q8: -7 Divide by 3 in binary restoring twos complement notation, using 4-bit words
Ans:
The divisor is placed in the M register, the dividend in the Q register. So, -7/3 (-7 is dividend and 3 is
divisor) Q=-7 and M=3
710=01112
Q= -7=1000+1=10012
M=310=00112
-M (2nd complement of M) = 1100+1 = 11012
If Q is sign number (negative number), sign bit 1111(4-bit) is placed in A.
If Q is sign number (positive number), sign bit 0000(4-bit) is placed in A.
A Q M Count Operation
1111 1001 0011 4 Initial
1111 0010 0011 Shift
0010 0010 A←A+M
1111 0010 3 Restore A, Q0=0
1110 0100 0011 Shift
0001 0100 A←A+M
1110 0100 2 Restore A, Q0=0
1100 1000 0011 Shift
1111 1000 A←A+M
1111 1001 1 Q0=1
1111 0010 0011 Shift
Page 6 of 10
0010 0010 A←A+M
1111 0010 0 Restore A, Q0=0
(c)-1.5
1.510 = 1.12 = 1.1 x 20
Sign bit is =1 (negative)
exponent = 127+0 = 011111112
So, IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
1 01111111 10000000000000000000000
1 01111111 10000000000000000000000
(d) 384
38410 = 384-256 = 128 -128 = 0; =28+27= 110000000 = 1.1 x 28
Sign bit = 0(positive)
Page 7 of 10
exponent = 8 + 127 = 135 = 10000111
So, IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
0 10000111 10000000000000000000000
0 10000111 10000000000000000000000
(e) 1/16
1/16 =. (0/2+0/4+0/8+1/16) = .0001 = 1.0 x 2-4
Sign bit = 0 (positive)
exponent = 127 – 4 = 123 = 01111011 So,
IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
0 01111011 00000000000000000000000
0 01111011 00000000000000000000000
(f) -1/32
1/32 =. (0/2+0/4+0/8+0/16+0/32) =.00001 = 1.0 x 2-5
Sign bit = 1(negative)
exponent = 127 – 5 = 122 = 01111010 So,
IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
1 01111010 00000000000000000000000
1 01111010 00000000000000000000000
Q.10 Consider a floating-point format with 8 bits for the biased exponent and 23 bits for the
significand. Show the bit pattern for the following numbers in this format: (a) -720 (b) 0.645
Ans:
(a)-720
720=29+27+26+24=10110100002=1.011010000×29
Sign bit= 1(negative)
Exponent=127+9=136=100010002
So, IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
1 10001000 01101000000000000000000
1 10001000 01101000000000000000000
(b)0.645
0.645×2=1.29 take 1
0.29×2=0.58 take 0
0.58×2=1.16 take 1
0.16×2=0.32 take 0
0.32×2=0.64 take 0
0.64×2=1.28 take 1
0.28×2=0.56 take 0
0.56×2=1.12 take 1
Page 8 of 10
0.12×2=0.24 take 0
0.24×2=0.48 take 0
0.48×2=0.96 take 0
0.96×2=1.92 take 1
0.92×2=1.84 take 1
0.84×2=1.68 take 1
0.64510= .10100101000111…….2=1.0100101000111……×2-1
Sign bit = 0 (positive)
Exponent=127+(-1) =126= 011111102
So, IEEE 32-bit floating point format is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
0 01111110 0100101000111………
Q11: 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
Ans:
(a) 1 10000011 11000000000000000000000
Sign bit = 1 (negative)
Exponent =131-127= -4
Significand (don’t forget the hidden bit in Significand)
= 1.11000000000000000000000×24 =11100=24+23+22=28
So, –28 (don't forget the hidden bit in Significand bit)
Page 9 of 10
Significand (don’t forget the hidden bit in Significand)
=1. 00000000000000000000000
So, 1. 00000000000000000000000×21=102=210
-------------------------------------------------------THE END--------------------------------------------------------
Page 10 of 10