Once again we have to create the functions that we wish to use on our large numbers. Simple Add, Subtract, Multiply, and Divide functions require our attention to insure speed in processing. Global structs provide us with the ability to use pointers to lessen the burdon of data movement on processing speed. At this point, one must decide if the operations are to be destructive, change the number we supply, or non-destructive, leaving the operands untouched. I have found that I usually need both functions, a destructive Add and a non-destructive Add.
For non-destructive Functions, a result struct is required, and at times intermediary structs. Processing speed is decreased, due to the movement of data from struct to struct.
An example of the need for a destructive Add, is the simple adding of a '1' to a number. If the number is even, a '1' is placed in the low order digit and we are finished. If the number is odd, a processing loop from low-order to high is used to logically determine what the digit is. The loop stops when the digit is zero when the carry is '1'.
Example: start = 4, stop = 10, digit[] = 00001101111
carry='1';
i=p->stop;
do
{
if((carry=='1')&&(p->digit[i]=='1'))
p->digit[i]='0';
else
{
p->digit[i]='1';
carry='0';
}
i--;
}while((carry!='0')&&(i>=p->start));
The result of the above function leaves the result: start = 4, stop = 10, digit[] = 00001111111
A provision for a high order overflow and size adjustment is also required, along with insuring that zeroes are present to stop the operation.
Pointer arithmetic is also possible, as well as other refinements.