Could anyone guide me on how to directly convert a number from base 3 to base 2 without using base 10? For example, converting "2101" (base 3) directly to base 2. Any suggestions, method or algorithms would be greatly appreciated.
Thanks in advance!
Could anyone guide me on how to directly convert a number from base 3 to base 2 without using base 10? For example, converting "2101" (base 3) directly to base 2. Any suggestions, method or algorithms would be greatly appreciated.
Thanks in advance!
There isn't really any issue with converting directly, exactly the way you would to base 10, only do it to base 2 instead. The biggest hurdle is probably to do all the base 2 arithmetic, because it's not something that people practice as much as they practice base 10 arithmetic.
In base 3, we have $$ 2101 = 2\cdot 10^3 + 1\cdot 10^2 + 0\cdot10^1 + 1\cdot 10^1 $$ Converting all of these numbers into base 2, we get: $$ 10\cdot 11^3 + 1\cdot 11^2 + 0\cdot 11^1 + 1\cdot 11^0\\ = 10\cdot 11011 + 1\cdot 1001 + 0\cdot 11 + 1\cdot 1\\ = 110110 + 1001 + 0 + 1\\ = 100\,0000 $$ (Note that I didn't bother to touch the exponents. They can stay in base 10 in my opinion.)
Instead of adopting a "base-three-to-base-ten" algorithm to suit your needs, we could adopt a "base-ten-to-base-two" algorithm. In this case repeated division by $2$, where all the remainders make up the representation we're after, in order from lowest significance to highest. The arithmetic involved here is base 3 division rather than base 2 multiplication:
All in all we reach $100\,0000$.