复旦计算机春季期末考试试题A
复旦大学计算机科学技术学院
《计算机原理》期末考试试卷
A卷 共 13页
课程代码:INFO130054.01-02 _考试形式:开卷 2010年6月
(本试卷答卷时间为100分钟,答案必须写在答卷上,做在试卷上无效)
专业学号姓名成绩
题号1234567总分得分
Number Conversion: IEEE 754 single precision 32-bit float standard representation with a little change is illustrated below.
Normalized: (-1)sign * (1.fraction) * 2exponent-127 (exp=1 to 254)
Denormalized: (-1)sign * (0.fraction) * 2-126(when exp=0, fraction≠0)
Zero: all 0’s in all 3 fields
Convert the number -35.390625 into this changed IEEE 754 FP single precision representation (in hex).
(-35.390625)10 = (0x )16
With changed 32-bit float representation, what is the equivalent value as a decimal number?
A: (0011 1111 0001 0000 0000 0000 0000 0000)2
B: (0000 0000 0011 0101 0000 0000 0000 0000)2
Calculate the sum of (35.390625)10 and (0011 1111 0001 0000 0000 0000 0000 0000)2 using changed 32-bit float representation, and then round the sum (in binary number value, e.g. (1000.11)2 for (8.75)10 ) to 4 bits to the right of the binary point by both round-up and round-down. Give your steps detailed.
Given three numbers f1, f2 and f3 of this changed 32-bit representation, none of them equals +(, -( or NaN, and x is signed 32-complement representation. Please tell whether two C expressions below are always true. If yes, give the reason in detail; If no, give a counterexample and show the detail computation steps to get false.
A: x = = (int) (float) x;
B: (f1 > f2) = = ((f1 + f3) > (f2 + f3))
Please read the following C code and assembly code and then fill in the blanks.
#include
int p[5][4] = {{43,56,78,69},{-7,89,7,23},{24,36,88,67},
{12,56,78,90},{62,93,-78,9}};
int main(void){
int result = cal(5,4);
printf("The result is %d\n", result);
}
int cal(int a, int b){
int i;
int result=0;
for ( i = 0; i < b; i++) {
if (i < a-1)
result -= i*p[i+1][i];
}
return result;