Consider this example: say we want to convert <em>x</em> = 11 0101 1001₂ to base 3.
The binary expansion of <em>x</em> is
<em>x</em> = 1×2⁹ + 1×2⁸ + 1×2⁶ + 1×2⁴ + 1×2³ + 1×2⁰
which in base 10 reduces to
<em>x</em> = 512 + 256 + 64 + 16 + 8 + 1 = 857
Recall the first several powers of 3:
3⁰ = 1; 3¹ = 3; 3² = 9; 3³ = 27; 3⁴ = 81; 3⁵ = 243; 3⁶ = 729
Now it's a matter of computing quotients and remainders. Pick the largest power of 3 that fits into the target number, then check the remainder and repeat.
• How many times does the 729 go into 857? 1 time, and it leaves a remainder of 128, or
857 = 1×729 + 128 = 1×3⁶ + 128
• How many times does 81 go into 128? Also 1 time, so
128 = 1×81 + 47 = 1×3⁴ + 47
• How many times does 27 go into 47? Also 1 time,
47 = 1×27 + 20 = 1×3³ + 20
• How many times does 9 go into 20? 2 times,
20 = 18 + 2 = 2×9 + 2 = 2×3² + 2
• How many times does 1 go into 2? Also 2 times,
2 = 2 + 1 = 2×1 + 0 = 2×3⁰
So we found
857 = 1×3⁶ + 1×3⁴ + 1×3³ + 2×3² + 2×3⁰
which is the ternary expansion of <em>x</em>,
<em>x</em> = 1 011 202₃