I have been trying to write a class that can handle bigInts (up to 40 digits long stored in a dynamic array of shorts) but I am having trouble overloading the addition operator. My logic is 99% of the way there, but the main issue is on line 16 where I am adding 1 to the i-1 of the LHS pointer (for the overflow). While it does the addition correctly after that, it is also editing the LHS itself, which pretty much ruins the whole program. The loop is traversing from right to left as well. I have attached what I have so far below.
N carry = 0;
for i = (least significant position) to (most significant position){
N x = left[i] + right[i] + carry;
result[i] = x % modulo;
carry = x / modulo;
}
if (carry > 0)
//overflow