Problem 1 (2 Points) : Homework # 2 Solutio
Problem 1 (2 Points) : Homework # 2 Solutio
Problem 1 (2 Points) : Homework # 2 Solutio
Problem 1 (2 points)
a. There are 313 characters in the Tamil language. If every character is to be encoded into
a unique bit pattern, what is the minimum number of bits required to do this?
8 bits can used to encode 28 = 256 characters and 9 bits can be used to encode 29 =
512 characters. So, we would need 9 bits.
b. How many more characters can be accommodated in the language without requiring
additional bits for each character?
Problem 2 (4 points)
a. 1010
First bit is 1. So it is a –ve number. 2’s complement of 1010 = 0101 + 1 = 0110. So the
answer is -6.
b. 0010
c. 111111
This is a –ve number since it starts with 1. Its 2’s complement is 000000 + 1 = 000001.
So the answer is -1
d. 011111
Problem 3 (4 points)
a. What is the largest positive number one can represent in a 16-bit 2's complement
code? Write your result in binary and decimal.
c. What is the largest positive number one can represent in a 16-bit signed magnitude
code? Write your result in binary and decimal.
d. What is the greatest magnitude negative number one can represent in a 16-bit signed
magnitude code? Write your result in binary and decimal.
Problem 4 (2 points)
What are the 8-bit patterns used to represent each of the characters in the string "This Is
Easy!"? (Only represent the characters between the quotation marks.)
Problem 5 (4 points)
Convert the following decimal numbers to 8-bit 2's complement binary numbers. If there is
problem while doing this, describe it.
a. 102
0110 0110
b. 64
0100 0000
c. 128
d. -128
1000 0000
Problem 6 (4 points)
The following binary numbers are 4-bit 2's complement binary numbers. Which of the
following operations generate overflow? Justify your answers by translating the operands
and results into decimal.
a. 0111 + 1101
No overflow.
0111
1101
--------
10100
b. 1001 + 1110
Overflow.
1001
1110
--------
10111
No overflow.
1111
1001
--------
11000
d. 0011 + 0101
Overflow.
0011
0101
--------
1000
Problem 7 (2 points)
A computer programmer wrote a program that adds two numbers. The programmer ran
the program and observed that when 5 is added to 8, the result is the character m. Explain
why this program is behaving erroneously.
The error that is occurring here is that 5 and 8 are being interpreted as characters ‘5’ and ‘8’
respectively. As a result, the addition that is taking place is not 5 + 8; rather, it is ‘5’ + ‘8’. If we
look up values in the ASCII table, 5 is 0x35 and 8 is 0x38. 0x35 + 0x38 = 0x6d, which is the
ASCII value for ‘m’.
Problem 8 (2 points)
a. OT(1011) OR (1011)
NOT(1011) = 0100
Problem 9 (4 points)
Write the decimal equivalents for these IEEE floating point numbers.
a. 0 01111111 11000000000000000000000
Exponent = 127.
= 1.75 * 20 = 1.75
b. 1 01111101 10000000000000000000000
Exponent = 125.
Given a black box which takes n bits as input and produces one bit for output, what is the
maximum number of unique functions that the black box can implement? (Hint: Try to
visualize a truth table for a single function of n bits. Determine how many rows such a
truth table has. Then determine how many combinations are possible with the number of
rows that you just found)
Consider a single function that this black box implements. If there are n binary inputs,
the truth table contains 2n rows.
Now, each of these rows in the truth table can be filled with 0 or 1. The number of ways
in which we can fill in these rows (using 0 and 1) gives us the number of unique
functions. Since each of the rows can be filled in using 2 possible values and since the
number of rows is 2n, the number of ways = 2 power (2n).