# Find corresponding digit string lengths between radices?

Each digit of base the base-16 representation of a number corresponds exactly to 4 digits in the base-2 representation, which allows for trivial conversion between these bases.

Other combinations of bases are less straightforward, but still permit short-cutting the generic remainder-and-divide algorithm for converting bases. E.g., 3 digits of base-16 correspond to 4 digits of base 8, and 3 digits of base-256 correspond to 4 digits of base-64 (hence the motivation for the base-64 encoding standard for binary data).

These sorts of relations are all fairly easily discoverable by comparing them to base-2 as an intermediary. But is there a more generic method of discovering whether or not a digit ratio exists between two radices, and if so, what it is?

Digits can be aligned between representations in different bases if there is a solution in integers for $$x$$ and $$y$$ in the equation $$r_1^x = r_2^y$$, where $$r_1$$ and $$r_2$$ are the radices of each base. This is equivalent to saying that an $$x$$-digit number in base $$r_1$$ can express the same range of values as a $$y$$-digit number is base $$r_2$$.
This in turn has a solution when each radix can be written as a power of a common base; i.e., $$r_1 = c^w$$ and $$r_2 = c^z$$, so $$r_1^x = c^{wx} = c^{zy} = r_2^y$$
The values of $$x$$ and $$y$$ then tell you how many digits in each base are needed to align with a block of digits in the other base.