0
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

Yes!

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.

The common base for 8, 16, 64, and 32 is base 2, which is why these can be converted between by lining up their bit patterns. However, a similar relationship holds between, e.g., base-27 and base-9 (where 2 base-27 digits correspond to 3 base-9 digits), which can be seen by aligning trit (base-3 digit) patterns.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.