The simple way to do this would be to convert the base 2 number to base 10, then convert that base 10 number to base 4 to get the answer.
However, I think that there might be an even better way to do this, because 4 happens to be 2*2, but I can't seem to pinpoint it. Can somebody please point me in the right direction?
$\endgroup$ 13 Answers
$\begingroup$The fact that $4=2\cdot 2$ is not important, but the fact that $4=2^2$ is. Each digit of the base $4$ representation corresponds to two bits of the base $2$ representation, so you can just start from the right end, convert every two bits to a base $4$ digit, and keep going. Similarly, you can convert base $2$ to base $16$ by taking the bits in groups of $4$ because $2^4=16$. Nothing special is available converting base $2$ to base $12$ even though $12=2\cdot 6$
$\endgroup$ $\begingroup$Suppose the number in base $2$ is $...a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}a_{0}$.
The number in base $4$ is simply $...a_{6}a_{4}a_{2}a_{0}+2\times(...a_{5}a_{3}a_{1})$.
For example, $H_{2}=10011101$ then $H_{4}=0111+2\times(1010)=2131$
$\endgroup$ $\begingroup$There is. Start by writing out the first few numbers in the two bases:$$\begin{array}{c|c}Base\ 4&Base\ 2\\\hline0&0\\1&1\\2&10\\3&11\\10&100\\11&101\\12&110\\13&111\\20&1000\\21&1001\\...&...\end{array}$$So just group 2 digits of base 2 into one digit of base 4.
$\endgroup$