# Negate an integer in a negative base

What is a simple algorithm you can feasibly do by hand to negate an integer in a negative base, such as negadecimal?

In positive bases, you can simply append a negative sign if it is not there, and remove it if it is:

Negate 123456
-> -123456
Negate -123456
-> 123456


In a negative base, however, it is not so easy, since both negative and positive numbers can be represented without any sort of explicit sign.

This should be the result in negadecimal:

Negate 123456
-> 98764
Negate 98764
-> 123456


I can't figure out a straightforward method (i.e. one that can be done with pencil and paper fairly mindlessly) to negate a negadecimal number. How could I do this?

• In a number and its negation, what happens if you add the corresponding digits? (answer 10, at least in your two examples: does that work in general?) – GEdgar Aug 30 '11 at 23:57

## 1 Answer

Working from the right, the two extreme digits must add up to 0 or 10 (and can only add to 0 if they are both 0). If they add to 10 then carry one from the next sum. The next two digits to the left must add up to 0 or 10 if not carrying one, or if carrying one then add up to 1 or 11; if they add up to 10 or 11 then carry one from the next sum. And so on.

So starting with say 120034:

• The negative must have 6 on the right as $4+6=10$, so carry one.
• The next digit of the negative must be 8 as $3+8=11$, so carry one.
• The next digit of the negative must be 1 as $0+1=1$, so do not carry one.
• The next digit of the negative must be 0 as $0+0=0$, so do not carry one.
• The next digit of the negative must be 8 as $2+8=10$, so carry one.
• The next digit of the negative must be 0 as $1+0=1$, so do not carry one.
• The next digit of the negative must be 0 as $0+0=0$, and so on.

But we can ignore left-hand leading 0s so the negative of 120034 is 80186.

• This old answer was of tremendous help for me, thank you. – student Feb 9 '16 at 23:08