Author(s): <your name(s)>
Due date: 2016/11/08
Note: Remember this is a C project.
Complete the following exercises, saving your solutions in the indicated files.
- Recall the following references, which will still be useful throughout the rest of the course.
- Note that a
bin
directory will be created bymake
. Pay attention to how it is used in what follows. Also pay attention to the added compiler flags in theMakefile
- Examine the source code in
src/bit_print
carefully. Compile and run it.- In a Jupyter notebook
BitPrint.ipynb
, describe whatprint_types
does in detail. Answer the following questions. - What are the integer values for the letters 'A', 'Z', 'a', and 'z'?
- What are the integer values for the numbers '0', '1', and '9' as characters?
- If you needed to store a 2D array of 10000x10000 complex numbers, how much memory would it require (in megabytes) if: a) the real and imaginary parts were each shorts? b) the real and imaginary parts were each long doubles? (Recall the prefixes: kilo = 10^3, mega = 10^6, giga = 10^9, tera = 10^12, peta = 10^15, exa = 10^18, zetta = 10^21, yotta = 10^24)
- Work out the algorithm for how the bit string for an unsigned int is interpreted as an integer. Describe this algorithm in your notebook.
- Work out the algorithm for how the bit string for a (signed) int is interpreted as an integer. How does this differ from an unsigned int? What are the maximum and minimum bounds of each? Describe this algorithm in your notebook.
- In a Jupyter notebook
- Examine the source code in
src/arrays
carefully. Compile and run it.- In a Jupyter notebook
Arrays.ipynb
, describe whatarrays
does in detail. Do the following. - Change the type of "array" to an array of floats. Make sure the code compiles and runs.
- Change the type of "memblock" to a pointer to long double. Make sure the code compiles and runs.
- Refactor
arrays.c
to add two new functions:print_arrays
andset_arrays
. Move the existing code frommain
into these new functions as appropriate, and call them frommain
. You will have to think carefully about what types these new functions should be, and what arguments (if any) they should have, of what type(s). Make sure the code compiles and runs. - In your notebook, explain what
malloc
andfree
do in detail.
- In a Jupyter notebook
- Examine the source code in
src/structs
carefully. Compile and run it.- In a Jupyter notebook
Structs.ipynb
, describe whatprint_structs
does in detail. Answer the following questions. - Explain the difference between "pass by value" and "pass by reference" in your own words. Support your explanation with concrete examples from the program output.
- Explain the difference between
v.x
andv->x
for a structv
with fieldx
.
- In a Jupyter notebook
- Examine the existing test in
test/
carefully. Compile and run it.- Add another test that reimplements the "pass by reference" test in
src/structs
. Ensure that it passes.
- Add another test that reimplements the "pass by reference" test in
Analyze in this section what you found useful about this assignment in your own words. Include any lingering questions or comments that you may have.
CHANGEME
I pledge that all the work in this repository is my own with only the following exceptions:
- Content of starter files supplied by the instructor;
- Code borrowed from another source, documented with correct attribution in the code and summarized here.
Signed,
YOURNAME