# What algorithm can I use to add negadecimal numbers?

I am trying to figure out how to add negadecimal numbers by hand.

I can add normal decimal numbers using an algorithm I learned in kindergarten: start with the least significant digits, add them, carry, move left, repeat.

 Carry: 1111 1
First:  156739
Second:  948352
=======
1105091


The same algorithm, however, yields incorrect results when trying to add negadecimal numbers.

If I add these two negadecimal numbers together, this should be the result:

 First:  156739
Second:  948352
========
19083071


but I am not sure what algorithm I can use to achieve this result. How can I add two negadecimal numbers?

You're very close. Look at the 1's place. In base 10 you would say $9+2=11$, so we put a 1 and carry a 1 into the 10's place.

In base -10, we must carry a -1 into the -10's place! So whenever you have a carry, you just carry a -1 into the next place.

This only becomes tricky if the next place has only 0's in it. In this case, since -1 = 19 (base -10), you would write down 9 and carry a +1 into the next place. (Essentially this is a borrow; since negative bases are able to represent positive and negative numbers without an explicit sign, addition and subtraction are the same operation, so it makes sense that your algorithm has to include both carries and borrows.)

Using this procedure, I got the correct answer for your sample problem.

• I've got it now. Thanks! – Peter Olson Aug 27 '11 at 17:27

I presume that by negadecimal, you mean base $-10$.

The addition algorithm is as usual (treating digits as positive), except that:

• carries are negative: if you have a carry of $1$ in some column, you must subtract $1$ from the sum of the two digits in that column

• if you ever get $-1$ as the result in some column, then you must put down $9$ and carry $-1$. (That is, in the next column, treat the carry of $1$ as positive).

For your example (I've added leading zeroes to make the carry at the last step clearer, and also used 'x' to stand for a negative carry of 1):

 Carry: x1 11 1
First:  0156739
Second:  0948352
========
19083071