You are on page 1of 6

EEE102

Sample Problems for Fall 2009


16-9-2009
NUMBER SYSTEMS and CODES
Q1.
Fill in the following table
Decimal

8-bit twos
complement

8-bit signedmagnitude

BCD

8-bit twos
complement
11110100

8-bit signedmagnitude
10001100

BCD

-12
Solution:
Decimal
-12

Q2.
Problem 2.1 from Wakerly 4th edition.
e) 10100.11012 = 14.D16
h) AB3D16 = 10101011001111012
j) 15C.3816 = 101011100.001112
Q3.
Problem 2.3 from Wakerly 4th edition.
a) 102316 = 10000001000112 = 100438
e) 9E36.7A16 = 1001111000110110.01111012 = 117066.3648
Q4.
Problem 2.7 from Wakerly 4th edition.
a)
carries

sum
d)
carries

sum

1 1 0 0
1 1 0
1 1
1 0 0 1

1
0
0
1

0
1
1
0

0
1
0
1

1 1
1
1
1 1

0
0
1
1

0
1
0
1

0
1
0
1

0
1
1
0

0
0
1
1

0
0
1
1

Q5.
Problem 2.11 from Wakerly 4th edition.
decimal

8-bit signed-

8-bit twos

Not applicable

25
120
82
-42
-6
-111

magnitude
00011001
01111000
01010010
10101010
10000110
11101111

complement
00011001
01111000
01010010
11010110
11111010
10010001

Q6.
Problem 2.12 from Wakerly 4th edition.
a) No overflow, result is 10111111
c) Overflow occurs
Q7.
Problem 2.16 from Wakerly 4th edition.
COFFEE
Q8.
Problem 2.18 from Wakerly 4th edition.
e)
302 / 20 = 12.1

302 = 20 12.1
302 x = 20 x 12.1x
1
3 x 2 + 2 = 2 x( x + 2 + ) = 2 x 2 + 4 x + 2
x
2
x = 4x
x = 4 (0 is not possible)
f)

41x = 5 x
41x = 5 x 5 x
4x +1 = 5 5
4 x = 24
x=6
Q9.
Problem 2.26 from Wakerly 4th edition.
The twos complement binary number 11110101 is -11 in decimal. Removing the leftmost 1s until
only one 1 remains on the left before a 0 we get 10101 which is again -11 in decimal.
For positive numbers we can remove the leftmost 0s until only one 0 is left before a 1.
This is not a rigorous proof. You may make a rigorous proof as follows.

X = xn1 2n 1 +

x 2

i =n2
0

Y = xm1 2m 1 +

xi 2i = xn d 1 2 n d 1 +

i=m2

xi 2i

i =nd 2

Let us write X again as


0

X = xn1 2n 1 + xn 2 2 n 2 + ... + xn1 d 2n 1 d +

xi 2i

i =n 2d
n 1

n2

n 1 d

= xn 1 2 + xn 2 2 + ... + xn 1 d 2
+ Y + xn 1 d 2n 1 d
In order for X to be equal to Y we must have
xn 1 2n 1 + xn 2 2n 2 + ... + xn 1 d 2n 1 d + xn 1 d 2 n 1 d = 0
or;
m

x2

xn 1 2n 1 + 2 xm 1 2m 1 +

=0.

i =n2

Which is true iff xn1 = xn 2 = ... = xm 1 . (show this)

Q10.
Problem 2.30 from Wakerly 4th edition.

Example: 11110101 multiplied by 2 is 11101010 by using the rules specified in the problem.(
Indeed -11 times 2 is -22)
Proof: Suppose B is the original twos complement n-bit binary number bn 1bn 2 ...b1b0 and C is
the n-bit twos complement number we obtain after the specified operation, bn 2 ...b1b0 0 .
0

Thus B = bn 1 2 n 1 +

bi 2i and C = bn 2 2n 1 +

i =n2

i 1

2i are the decimal equivalents

i = n 2

of the two numbers.


But
0

2 B = bn1 2n +

b 2
i

i +1

= bn 1 2n + bn 2 2n 1 +

i= n2

b 2
i

i +1

= bn 1 2n + bn 2 2n 1 +

i = n 3

Thus the condition for C be equal to 2B is bn 1 2 n + bn 2 2n 1 = bn 2 2n 1 .


bn1 2 + bn 2 = bn 2 bn 1 2 = 2bn 2 bn1 = bn 2 .
The overflow condition is bn1 bn 2 .
Q11.
Find the BCD code for 12910.
Answer 000100101001

b
j =n2

j 1

2i

Q12.
Fill in the following table

Decimal

twos complement

6-bit signedmagnitude

BCD of magnitude
only

6-bit signedmagnitude
101001

BCD of magnitude
only
1001

6-bit signedmagnitude

BCD of magnitude
only

6-bit signedmagnitude
100111

BCD of magnitude
only
0111

111110111
Solution:
Decimal

twos complement

-9

111110111

Q13.
Fill in the following table

Decimal

twos complement
111111001

Solution:
Decimal

twos complement

-7

111111001

Q14.
Convert 12.310 to binary
Solution:
12
6
0
3
0
1
1
0
1

0.3
0.6
1.2
0.4
0.8
1.6
1.2
0.4
0.8
1.6

0
1
0
0
1
1
0
0
1

1.2 1
0.4 0
Therefore the result is 1100.0100110011.....2
We can also write this as 1100.010012
Let us check if our result is correct
1 1 1 1 1 1 1 1
0.010012 = + + + + +
+ ...
4 32 4 32 16 4 32 256
9
1
1
= (1 + +
+ ...)
32
16 256
1
1
+
+ ...
16 256
x
1
1
= +
+ ... = x 1
16 16 256
Then x = 16 x 16
16
x=
15
9
1
1
9
9 16 9
3
0.010012 = (1 + +
+ ...) =
x=
=
=
= 0.3
32
16 256
32
32 15 30 10

Call x = 1 +

Therefore 1100.010012 = 12 + 0.3 = 12.3


Q15.
Perform the following number system conversions

a)

(1011010)2 =

( 5 A ) 16

b)

(147)8

c)

(AB.CD)16 = ( 10101011.11001101 )2
= ( 253.632 ) 8

= ( 1100111 ) 2

Q16.
Add the following 5-bit binary numbers in twos complement representation to obtain 5-bit
binary results in twos complement representation. For each case, indicate whether overflow
has occurred or not.
100100
a)
11010
10011
+_________
01101
overflow has occured

b)

c)

d)

111100
11110
11111
+_________
11101

overflow has not occured

111100
01010
11111
+_________
01001

overflow has not occured

011100
01110
01111
+_________
11101

overflow has occured

You might also like