BigInt, CPS 100, Spring 1996

Due Date

Part I is due January 22, 8:00 am.

Introduction

The files for this assignment can be found in ~ola/cps100/bigint+ on the acpub system. An itemized list of files included below, source is attached at the end of the handout, (the files are accessible via the world-wide web).

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).


Outline

There are two parts to this assignment. The first part is due in about one week, the second part in three weeks. You should be thinking about and working on the second part while you're doing the first part (the second part will be given out next week). The first part has two subparts. These are outlined below; particulars can be found in the sections that follow. Part I (two parts)

Compiling

You can create an executable program from fact.ccby typing make fact, the Makefile will take care of the details. Running the program prompts for a number and then prints factorials from the entered number down to 1. If you invoke the program with a command-line argument as in \verb!fact 14! it will compute and print all factorials from the command-line argument down to 1.

You can compile your program for testing division (if you name it testdiv.cc) by typing make testdiv.

Details of Assignment

Run the program with an input of 3, so that 3!, 2! and 1! are computed. You must then explain how/why each diagnostic line of output is generated.

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.


Submitting

You should create a README file for this and all assignments. All README files should include your name as well as the name(s) of anyone with whom you collaborated on the assignment and the amount of time you spent. They should also include your impressions of the assignment and any writeup required by the assignment.

To submit use the command

   submit100 bigint1 README bigint.h bigint.cc testdiv.cc
You 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