Question 1 Not yet answered Points out of 100 Flag question
Question 1
Not yet answered
Points out of 1.00
Flag question
Question text
Assuming two\'s complement representation and 8 bits, give the binary for -3.
Answer:
Question 2
Not yet answered
Points out of 1.00
Flag question
Question text
Assuming two\'s complement representation and 4 bits, give the binary for -3.
Answer:
Question 3
Not yet answered
Points out of 1.00
Flag question
Question text
What is the fewest number of bits needed to represent the value -3 in two\'s complement? In other words, if you could create arbitrary length ints (17 bits, 5 bits, etc.) what is the smallest length that you could use that would still support the representation of -3?
Answer:
Question 4
Not yet answered
Points out of 1.00
Flag question
Question text
What is the output of the following C code?
int x = 0x000000ff;
x = (signed char) x;
printf(\"%d\ \", x);
Answer:
Question 5
Not yet answered
Points out of 1.00
Flag question
Question text
Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
The sum of the 8-bit two\'s complement numbers 0111 0011 and 1011 0000 results in
Select one:
a. 0010 0011 and a negative overflow
b. 0010 0011 and no overflow
c. 0000 0011 and a negative overflow
d. 1111 0011 and no overflow
e. 0000 0011 and no overflow
f. 0010 0011 and a positive overflow
Question 6
Not yet answered
Points out of 1.00
Flag question
Question text
Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
The sum of the 8-bit two\'s complement numbers 1100 1101 and 1000 0111 results in
Select one:
a. 0101 0101 and a negative overflow
b. 0101 0100 and no overflow
c. 0101 0100 and a positive overflow
d. 0101 0100 and a negative overflow
e. 0111 0101 and a negative overflow
f. 0111 0101 and no overflow
Question 7
Not yet answered
Points out of 1.00
Flag question
Question text
Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
Assume the two numbers below are 8-bit two\'s complement.
The result of 0111 1101 minus 1011 1101 is:
Select one:
a. 1100 0000 and a negative overflow
b. 1100 0000 and a positive overflow
c. 0100 0000 and a positive overflow
d. 0101 0101 and a negative overflow
e. 0100 0000 and no overflow
f. 0100 0001 and a negative overflow
Question 8
Not yet answered
Points out of 1.00
Flag question
Question text
Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
Assume the two numbers below are 8-bit two\'s complement.
The result of 0111 1101 minus 0011 1101 is:
Select one:
a. 1100 0000 and a negative overflow
b. 0100 0001 and a negative overflow
c. 1100 0000 and a positive overflow
d. 0100 0000 and no overflow
e. 0100 0000 and a positive overflow
f. 0101 0101 and a negative overflow
Question 9
Not yet answered
Points out of 1.00
Flag question
Question text
Given the following computation:
result = B - A;
and that signB, signA, and signR are equal to the signs of B, A, and result respectively (either 0 or 1), which of the following statements expresses how to determine whether the subtraction caused an overflow?
Select one:
a. (signB != signR)
b. ((signA != signB) && (signB != signR))
c. (signA != signR)
d. ((signA == signB) && (signB != signR))
e. ((signA == signB) && (signB == signR))
f. ((signA != signB) && (signB == signR))
Question 10
Not yet answered
Points out of 6.00
Flag question
Question text
Assuming that result and ux are unsigned ints, select the C statement that computes the same result as the given C statement.
Question 11
Not yet answered
Points out of 1.00
Flag question
Question text
X represents an 8 bit signed value that is shifted right (arithmetically) by K bits. According to the discussion in the book, this will sometimes produce the value equivalent to X/(2K), but sometimes not. For the X and K values below, answer YES if this does produce X/(2k) or NO if it does not.
X = 0001 1001, K = 1
Answer:
Question 12
Not yet answered
Points out of 1.00
Flag question
Question text
X represents an 8 bit signed value that is shifted right (arithmetically) by K bits. According to the discussion in the book, this will sometimes produce the value equivalent to X/(2K), but sometimes not. For the X and K values below, answer YES if this does produce X/(2k) or NO if it does not.
X = 1101 1001, K = 1
Answer:
Question 13
Not yet answered
Points out of 1.00
Flag question
Question text
X represents an 8 bit signed value that is shifted right (arithmetically) by K bits. According to the discussion in the book, this will sometimes produce the value equivalent to X/(2K), but sometimes not. For the X and K values below, answer YES if this does produce X/(2k) or NO if it does not.
X = 1101 1100, K = 2
Answer:
Question 14
Not yet answered
Points out of 1.00
Flag question
Question text
X represents an 8 bit signed value that is shifted right (arithmetically) by K bits. According to the discussion in the book, this will sometimes produce the value equivalent to X/(2K), but sometimes not. For the X and K values below, answer YES if this does produce X/(2k) or NO if it does not.
X = 1101 1101, K = 3
Answer:
Question 15
Not yet answered
Points out of 1.00
Flag question
Question text
X represents an 8 bit signed value that is shifted right (arithmetically) by K bits. According to the discussion in the book, this will sometimes produce the value equivalent to X/(2K), but sometimes not. For the X and K values below, answer YES if this does produce X/(2k) or NO if it does not.
X = 1101 1000, K = 3
Answer:
| result = (ux << 4) + (ux << 2); | Answer 1Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
| result = ux << 5; | Answer 2Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
| result = ((ux << 3) - ux) >> 2; | Answer 3Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
| result = (ux << 5) + (ux << 3) + (ux << 2) + ux; | Answer 4Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
| result = ux >> 5; | Answer 5Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
| result = ((ux << 5) - (ux << 3) - ux) >> 3; | Answer 6Choose...result = ux * 32;result = ux / 32;result = ux * 20;result = ux * 45;result = 7 * ux / 4;result = (ux * 23) / 8; |
Solution
1. Assuming two\'s complement representation and 8 bits, give the binary for -3.
Answer:
00000011 <- 8 bit binary representation of 3
11111100 <- 1\'s complement of 3
+ 1 <- adding binary 1 to convert 1\'s complement of 2\'s complement
---------
11111101 <- 8 bit Binary of -3
2. Assuming two\'s complement representation and 4 bits, give the binary for -3.
Answer:
0011 <- 4 bit binary representation of 3
1100 <- 1\'s complement of 3
+ 1 <- adding binary 1 to convert 1\'s complement of 2\'s complement
---------
1101 <- 4 bit Binary of -3
3. What is the fewest number of bits needed to represent the value -3 in two\'s complement? In other words, if you could create arbitrary length ints (17 bits, 5 bits, etc.) what is the smallest length that you could use that would still support the representation of -3?
Answer:
Minimum 3 bit is required. Because minimum 2 bit is required to represent 3. we need one more bit to represent the -ve sign as sign bit.
4. What is the output of the following C code?
int x = 0x000000ff;
x = (signed char) x;
printf(\"%d\ \", x);
Answer:
It would print -1
0x000000ff is a hexadecimal number which is equivalant to decimal 255
So, at the first line value of the x is 255
In next line x is assigned by x as signed char. As the range of signed char is -128 to 127 but we are trying to convert a value out of it\'s range a gurbage value -1 is assigned to x
5. Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
The sum of the 8-bit two\'s complement numbers 0111 0011 and 1011 0000 results in
Answer:
a. 0010 0011 and a negative overflow
Because if we add two 2\'s complement number we get
10110000
01110011
---------
100100011
We can see that we are getting a 9 bit result by adding two 8 bit binary. So 1 bit is overflowed. As the overflowed bit(9th bit) is 1 it signifies the number is a negetive number.
6. Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
The sum of the 8-bit two\'s complement numbers 11001101 and 10000111 results in
Answer:
d. 0101 0100 and a negative overflow
Because if we add two 2\'s complement number we get
11001101
10000111
---------
101010100
We can see that we are getting a 9 bit result by adding two 8 bit binary. So 1 bit is overflowed. As the overflowed bit(9th bit) is 1 it signifies the number is a negetive number.
7. Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
Assume the two numbers below are 8-bit two\'s complement.
The result of 01111101 minus 10111101 is:
Answer:
e. 0100 0000 and no overflow
Because if we add two 2\'s complement number we get
11001101
- 10000111
----------
1000000
We can see that we are getting a 7 bit result by substructing two 8 bit binary. So there is no overflow.
8. Recall that a negative (positive) overflow occurs when an arithmetic computation produces a large negative (positive) result that can not be stored in the number of bits allotted.
Assume the two numbers below are 8-bit two\'s complement.
The result of 01111101 minus 00111101 is:
Answer:
d. 0100 0000 and no overflow
Because if we add two 2\'s complement number we get
01111101
- 00111101
----------
1000000
We can see that we are getting a 7 bit result by substructing two 8 bit binary. So there is no overflow.
9. Given the following computation:
result = B - A;
and that signB, signA, and signR are equal to the signs of B, A, and result respectively (either 0 or 1), which of the following statements expresses how to determine whether the subtraction caused an overflow?
Answer:
b. ((signA != signB) && (signB != signR))






