converting decimals to base negative-10

937 Views Asked by At

I have a decimal (base $10$) number, $44$, and would like to convert it to base $-10$. I know how to convert $$ 164_{-10} \mapsto 44_{10}, $$ but not the other way around.

2

There are 2 best solutions below

0
On

The simplest way is to simply carry and 'borrow' as needed, keeping track of odd vs. even digit positions. For your example, $44 = 4\times 10^1+4\times 10^0$. The ones' digit is clearly the same, so now we can concentrate on the tens' digit. Since $4=10-6$, we can express $4\times 10^1=40$ by borrowing from (or carrying into) the hundreds' digit; $40 = 4\times 10^1$ $= 10\times 10^1 - 6\times 10^1$ $= 1\times 10^2 - 6\times 10^1$ $= 1\times (-10)^2 + 6\times (-10)^1$; in other words a digit $d\gt 0$ in any 'odd' position (10s, 1000s, etc.) converts to a digit $d'=10-d$ in that position and a carry of $1$ into the next digit up. This can sometimes lead to a cascading effect of borrows and carries; for instance, imagine trying to convert $N=944_{10} = 9\times 10^2 + 4\times 10^1 + 4\times 10^0$. The ones' place is trivial, as before; and as before, we borrow/carry from the hundreds' place to invert the teens; $N = 9\times 10^2 + 1\times 10^2 - 6\times 10^1 + 4\times 10^0 = 10\times 10^2 - 6\times 10^1 + 4\times 10^0$. Now, this would 'carry' into the thousands' place as a positive digit: $N=1\times 10^3-6\times 10^1 + 4\times 10^0$, forcing us to do one more round of borrowing, turning $d=1$ into $10-d'=10-9$ : $N=1\times 10^4 - 9\times 10^3 + 0\times 10^2 - 6\times 10^1 + 4\times 10^0$ $=1\times (-10)^4 + 9\times (-10)^3 + 0\times (-10)^2 + 6\times (-10)^1 + 4\times 10^0$ $= 19064_{-10}$.

0
On

You do this as you would any normal base: you divide by -10 repeatedly and take the floor and remainder, except you start out with 44 as negative. $$\frac{-44}{-10}=4+\frac{4}{10}$$ $$\frac{4}{-10}=-1+\frac{6}{10}$$ $$\frac{-1}{-10}=\frac{1}{10}$$ So you obtain $44_{10}=164_{-10}$