| CompOrg Spring 2005 - HW1 FAQ |
|   CompOrg Home   |   HW1 Assignment |
+ Using the pow function (math library)
|
Question: | I was wondering if it was legal to use math.h's "pow(double, double)" function for the binary_to_int function. (I use it to calculate powers of two.) The reason for my concern is that the sample main.c code had several #includes, but math.h was not one of them. |
|
Answer: | You can use math functions, we will make sure it is linked with -lm. You need to make sure <math.h> is included in your code. Note that there are much easier ways (logic operations instead of using the pow function...). |
+ Powers of 2 using logic operations?
|
Question: | How can I compute powers of 2 using logic operations? |
|
Answer: | Recall that a left shift (of an integer) corresponds to doubling
the value, so the expression |
+ Re-submitting
|
Question: | I don't seem to be able to re-submit! |
|
Answer: | It's fixed now. |