Subtraction is really just addition where the second operand is multiplied by -1 before evaluation. You can't simplify it by changing the order of operands as you're doing, though.
If the minuend is greater than the subtrahend you can use complement to 9.
Change every digit of the subtrahend to 9-digit, sum 1 and then sum the numbers.
Example:
the original function assumes that the two integer arrays represent the individual digits of arbitrarily large integers.
it then proceeds to add these two large integers together using the addition procedure taught it grade school. rather
than returning the result as a third integer array, it converts it to a human readable string.
op now wants to write a similar function that subtracts the two large integers.
the answer for OP is first to understand exactly how the above function works, then think about how subtraction
is taught in grade school and then implement that. if a - b < 0, then borrow a one from the next column (instead
of carrying) and perform ( 10 + a ) - b.
Let A and B be two integers held as arrays of digits. Let Aones and Bones be the ones digit of A and B respectively.
Assume that the function is to compute S = A - B.
If Aones >= Bones, then Sones = Aones - Bones.
If Aones < Bones, then Sones = ( 10 + Aones ) - Bones, and remember to subtract 1 from Atens.