0% found this document useful (0 votes)
19 views

Chapter 2 Exercise and Answer Sign

Uploaded by

PAING LIN HTIKE
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Chapter 2 Exercise and Answer Sign

Uploaded by

PAING LIN HTIKE
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Cha

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:

+6 00000110 -6 11111010 +6 00000110 -6 11111010


+13 00001101 +13 00001101 -13 11110011 -13 11110011
+19 00010011 +7 00000111 -7 11111001 -19 11101101

Page 1 of 10
Multiplication of Unsigned number

Booth algorithm for two complement multiplication

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.

Ans: x=510=01012 (Multiplicand ,M), y=-610=10102(Multiplier,Q)


-M (2nd complement of M) =1010+1=10112

A Q Q-1 M Count Operation


0000 1010 0 0101 4 Initial
0000 0101 0 0101 3 Shift
1011 0101 0 0101 A←A-M
1101 1010 1 0101 2 Shift
0010 1010 1 0101 A←A+M
0001 0101 0 0101 1 Shift
1100 0101 0 0101 A←A-M
1110 0010 1 0101 0 Shift

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

A Q Q-1 M Count Operation


000000 010111 0 010011 6 Initial
101101 010111 0 010011 A←A-M
110110 101011 1 010011 5 Shift
111011 010101 1 010011 4 Shift
111101 101010 1 010011 3 Shift
010000 101010 1 010011 A←A+M
001000 010101 0 010011 2 Shift
110101 010101 0 010011 A←A-M
111010 101010 1 010011 1 Shift
001101 101010 1 010011 A←A+M
000110 110101 1 010011 0 Shift

The result = A Q = 000110 110101= 28+27+25+24+22+20= 437

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

A Q Q-1 M Count Operation


000000 011101 0 010111 6 Initial
101001 011101 0 010111 A←A-M
110100 101110 1 010111 5 Shift
001011 101110 1 010111 A←A+M
000101 110111 0 010111 4 Shift
101110 110111 0 010111 A←A-M
110111 011011 1 010111 3 Shift
111011 101101 1 010111 2 Shift
111101 110110 1 010111 1 Shift
010100 110110 1 010111 A←A+M
001010 011011 0 010111 0 Shift
9 7 4 3 1 0
The result = AQ=001010 011011= 2 +2 +2 +2 +2 +2 =667

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

Division of unsigned binary number

Two complement division (Restoring Division) for sign numbers.

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

Sign of dividend & divisor are different


Remainder A=11112= 0000+1=00012= -110 (by using twos complement)
Quotient Q=00102 =1101+1=00102= -210

Q9: 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
Ans:
(a) -5
510 = 1012 = 1.01 x 22
Sign bit =1 (negative)
exponent = 127 + 2 = 129 = 10000001
So, IEEE 32-bit floating point format is

Sign of significand(1bit) bias exponent(8-bits) Significand(23-bits)


1 10000001 01000000000000000000000
1 10000001 01000000000000000000000
(b) -6
610 = 1102 = 1.10 x 22
Sign bit is =1(negative)
exponent = 127 + 2 = 129 = 100000012
So, IEEE 32-bit floating point format
is
Sign of significand(1bit) bias exponent (8 bits) Significand (23 bits)
1 10000001 10000000000000000000000
1 10000001 10000000000000000000000

(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)

(b) 0 01111110 10100000000000000000000


Sing bit = 0 (positive)
Exponent=126-127=-1
Significand (don’t forget the hidden bit in Significand)
=1.10100000000000000000000×2-1=0.11012=(1/2+1/4+0/8+1/16)=13/16=0.8125
So,0.8125

(c) 0 10000000 00000000000000000000000


Sign bit = 0 (positive)
Exponent=128-127=1

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

You might also like