You should create a directory cps100 in which all work for this class will be done (see the initial Unix/Emacs/C++ writeup). Each assignment should be done in its own subdirectory, for this assignment create a directory bigint. All work for your assignment will then be done in the directory ~/cps100/bigint. You should change the acl (access control list) on your cps100 directory to give the professor (and TA/UTA) permission to read your files. The command below will give Owen Astrachan (login id 'ola') read permission on the directory cps100.
fs setacl cps100 ola read
Copy the files for this assignment into your bigint directory. To do this, cd into the bigint directory you created and type
cp ~ola/cps100/bigint/* .
don't forget the final . (dot).
6 <= 20
6 + 6 <= 20
6 + 6 + 6 <= 20
6 + 6 + 6 + 6 > 20
Therefore, 20/6 is 3. Accumulate a sum until it gets too large, and
count how many times the sum was accumulated. You must also write
a test program to show that your division works.
You can compile your program for testing division (if you name it testdiv.cc) by typing make testdiv.
For this part of the assignment you need only submit a writeup that explains why each line is printed. You can save the output in a file by typing
fact 3 > fact3.out
which will save the output in the file named fact3.out.
Only two lines of output will be stored in this file,
however, since most of the
most of the
diagnostic output is printed to the stream cerr (standard error)
rather than cout (standard out). To capture all output in a file,
run it using
fact 2 >& fact2.out
where the redirection symbol & captures both standard error and
standard out in the specified file. If the system responds that the
file already exists, you can use
fact 2 >& ! fact2.out
where the bang (exclamation mark) indicates that the file should be
overwritten.
After you have run the program, you'll want to remove the debugging
statements. To do this you'll need to edit the Makefile.
Remove the DDEBUG from the line in the Makefile reproduced
below.
CFLAGS = -g -DDEBUG
You'll then need to remove bigint.o and recompile. After doing this, run the program so that it computes all factorials from 40 downto 1. Submit this run with your explanation of the constructors/destructors.
You should also compile and run the program expo. Use it to compute the value of 4^25 (1125899906842624). The function Expo2 uses only 6 multiplications whereas Expo uses 25. Yet Expo2 takes much longer. In your README file you should explain why this is the case. As a hint, look carefully at how operator *= is implemented.
To submit use the command
submit100 bigint1 README bigint.h bigint.cc testdiv.ccYou can do this by typing make submit assuming all files are in the same directory. If you get a command not found error message, type ~ola/bin/submit100 instead of just submit100