Final Exam Solutions
CS 213 Fall 2004
Copyright By PowCoder代写 加微信 powcoder
Denormalized numbers
B. 255/256
Normalized numbers
D. 511/256
We have infinity or NaN when exp == 0x7f. We have a denormalized
number when exp == 0x0. For denormalized numbers, exps stays at 0. but
we shift frac to the right by 1. For everything else, just decrement
No answer provided.
No answers provided.
B. The code enters into an infinite loop, segfaulting and long
B. 4/3 CPE
A. x << 3 + x << 1 B. a + ~ b + 1 A. 0xFFFFFFFF C. func(a) & 1 No answer provided. Answers in order of blanks: .L2, %edx, %ecx, %eax %ecx, %edx, %eax movl 0x4(%eax),%eax, after line 14. B. Yes, Line 2 then line 13. C. yes, Any ordering of lines 2, 11, and 20. Problem 10 %% Answer: The basic bug is that the client is mixing buffered and %% unbuffered input. The call to will read in an entire %% packet, which includes both the length information and the data %% The call to ignores any remaining data in the buffer %% and therefore skips over the actual data. The first time, it will %% pick up the first 5 characters of the next packet. After that it gets %% really lost. %% Change the call to to %% I.e., replace line 10 with: %% n = Rio_readnb(&rio, buf, len); %% That way the client will pick up any data that has been read %% into the buffer. %% Break the server write into two parts: first send the length information %% and then send the data (with a sleep in between) %% I.e., replace lines 5 & 6 with %% sprintf(buf, "Content-Length: %d\r\n", len); %% Rio_writen(clientfd, buf, strlen(buf)); %% sleep(1); %% Rio_writen(clientfd, data, len); %% That way, the client's call to will get the data. D. No answer given. Problem 11 A. Y = H, Z = C C. C/(4*B) D. 1.25C or 1.25C-B+1 E. (B-1)/B F. P/B + H Problem 12 Answer not provided. Problem 13 double foo; /* SE */ double abc; /* OK L */ int *foo_ptr; /* SE */ int cnt; /* OK G */ double xyzzy; /* OK L */ int bar = 0; /* SE */ double eps = 1e-6; /* LE */ int MAX_N = 99; /* OK L */ unsigned *dead; /* SE */ static int beaf; /* OK L */ 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com