What did I do wrong in calculating $765_{18} - 210_{3}$?

52 Views Asked by At

So I wanted to calculate

$$765_{18}- 210_{3}$$

First converting $765_{18}$ into decimal: $765_{18} = 2381_{10}$.

Then converting $2381_{10}$ into binary: $2381_{10} = 100101001101_2$

Now converting $210_3$ into decimal: $210_3 = 21_{10}$

Two-complement of $21_{10} = 101011_{2}$

So I now want to add $2381_{10} +(- 21_{10})$ in binary (I just add the binary of $2381_{10}$ with the two-complement of $21_{10}$):

$$ 100101001101_2 + 101011_2 = 100101111000_2$$

I should get $2360_{10}$, but instead, I get $2424_{10}$.

1

There are 1 best solutions below

1
On BEST ANSWER

After a hint in the comment I realized that I had to use $12$ bits for $21_{10}$, i.e. $-21_{10} = 111111101011_2$

Now one only has to add both of these:

$$100101001101_2 + 111111101011_2 = 100100111000_2 = 2360_{10}$$