![]() |
|
|
Question: If I work in a team with one other person for lab 1, do we each have to submit a copy of the solutions? Or is one copy per team sufficient? Answer: One submission per group is all that we need.
Question: I notice some references to "15213-f01", should these be "15213-s02"? Answer: Yes. We're very sorry about that. The puzzles were changed since last semester, but it looks like, in the process of editing things, we missed some of the places where the semester was hard-coded. The materials were corrected -- but unfortunately it was too late for those who got copies early. You might want to pull down a new copy and use the new version of the Makefile. We'll do better in the future.
Question: I have no idea how to get started on reverseByte. do I want to switch just the hex around? am I allowed to use separate storage ints to store intermediate phases of it? how do you recommendI go about it? Answer: For reverseByte, you can't just switch the digits of the hex around. Since each digit in hexadecimal represents 4 bits and you want to reverse by the byte, you must reverse the number by every 2 digits of hex.
Question: ok, so I started isNonZero. so far what I have is a tree of or's- or-ing the first 16 bits with the second 16 bits, then 8, then 4, all the way down to one. the good news is it returns the right answer. the bad is that it uses 12 operations, not 10. do you recommend taking a different approach, or is there something I could do to simplify this one? Answer: I think there's probably a better approach out there. Be creative!
Question: Just wanted to double check.. you are only counting the operators and not equals sign or assignments (ie int a = 4)? Answer: No. The assignements are not counted.
Question: Is fitsBits(x, 0) a valid test case for fitsBits? Answer: No. The second parameter of the function must be at least 1 and no greater than 32.
Question:
I wrote the following code. What's the problem?
Answer: The problem is that, in C, although it is okay to initialize variables when you declare them, they must be declared "on top", before any other tyoe of real code.
Question: What should "dlc" output if the code follows the rules? Answer: It should be quiet, indicating no problems.
Question: When I type "make btest", I get "bash: make: command not found". Why is that? Answer: If make doesn't seem to be working, you probably need to add /usr/ccs/bin to your path.
Question:
What is the commands I need to compile and run my bits.c?
I tried different ones, but it shows error message :
Answer: Please try using the provided Makefile. The main() function isn't actually in "bits.c". Instead, it lives in "btest.c". "bits.c" really just holds the bitwise functions that you are asked to implement, plus some stuff needed for administrative purposes. The Makefile will build all of the parts for you and link them together to form the "btest" executible.
Question: For one of the puzzles, the write-up says: Answer: It can actually be done either way within the prescribed number of operations, and it really doesn't change the problem very much.
Question: I'm having some trouble figuring out how to do the leastBitPos function for the lab. Any suggestions? Answer: Think about the properties of bit-wise integer addition with respect to the carry-out from each bit-wise add. Under what circumstances will this carry-out occur? Under what circumstances will it "spill over" and cause a carry that otherwise wouldn't have happened? Under what circumstances will a carry-in be absorbed (a bit-wise addition, including the carry-in, does not cause a carry-out)?
Question: Does carry-out or carry-in mean that a value is being pushed over to the next power after an addition? Answer: Yes. After an add overflows, a 1 is "carried out" and placed into the next column. From the perspective of the next addition, this value is "carried in".
Question: In bits.c, it says that we may assume that the machine "has unpredictable behavior when shifting an integer by more than the word size." Does this mean I cannot assume that by shifting an integer 32 bits to the left, I will end up with 0x00000000? Answer: Given a 32-bit type, you should not right-shift by more than 31 positions. If you do, the results are, in fact, non-deterministic. In general, the results of >> are indeterministic for shifts equal to or wider than the data type.
Question: Does the same [non-deterministic if shifted more than 31] apply to left shift (<<)? Answer: Yes. |