Assignment IV

Due date Oct. 27, 2003

In this assignment you will use a linked representation to implement arbitrary precision arithmetic. The file describes a class that can be used to represent numbers of arbitrary size as lists of digits in base 10. The class also implements an addition operation. The assignment consists in adding a multiplication operation to the class.
The algorithm is very similar to the paper-and-pencil algorithm for long multiplication: compute the product of the multiplicand by each digit of the multiplier, shift the result by one place for each digit of the multiplier, and add the results. The main difference with this ancient technique is that you add partial results as soon as they are computed, rather than collecting all of them and then adding them in one step at the end.

You need to create two new methods: one to multiply a Number by ten, and the other to multiply a Number by a single digit. The multiplication method uses these two methods, as well as the addition method already provided.

Finally, you need to write a method Equals, to test the equality of two Numbers.

Test your program by generating three large numbers, say A, B and C, and then verifying that (A*B) * C = A * (B*C), or using any other arithmetic identity. To create large numbers, you can write a simple exponentiation method, that uses the multiplication method in a loop. Then, as an example, you could verify that (X^100) * (y^100) = (X*Y)**100 (where '^' denotes exponentiation).