title: Large integer radix/base conversion from 10^x to 2^x
body: <h2>Preface</h2>
  <p>I'm learning about computer math by writing and refining my own BigInt library. So far my first incarnation stores every digit of a base 10 number in successive elements of a vector. It can multiply and add with arbitrary precision. I want to speed it up by using all of the space available to me in a standard C++ data type by converting to base 2^x.</p>
  <h2>Information</h2>
  <p>I am reading 1000 or more digits from stdin in base 10 and I wish to convert them to base 2^x so I may store them easily in an array or vector of one of the standard C++ data types, likely unsigned int. I have only one idea for how to do base conversion, the repeated division with remainder method.  Here is some C++ code describing that method:</p>
  <pre><code>vector&lt;int&gt; digits;
  while(num!=0) {
     int mod = num%base;
     num = num/base;
     digits.push_back(mod);
  }
  </code></pre>
  <h2>Conundrums</h2>
  <p>Some things I'm lost on are whether or not division with remainder is the proper way to do radix conversion on large integers. I've tried looking at how the <strong>GMP library</strong> does it. <a href="http://pastebin.com/CqBEwnRN" rel="nofollow noreferrer" title="set_str.c -- Pastebin">gmp/mpn/generic/set_str.c</a> is the relevant c source file where &quot;the magic&quot; happens, but I am not certain what is going on in there. Matt McCutchen's <strong><a href="https://mattmccutchen.net/bigint/" rel="nofollow noreferrer">BigInt</a></strong> appears to use the repeated division with remainder method. If I do use this method, I essentially need write two versions of my BigInt class, one for working in Base10 and the other for Base2^x.</p>
  <h2>Conclusion</h2>
  <ul>
  <li>Offer advice on the proper steps for converting a huge number from a string to an array of 32 bit words.</li>
  <li>Help me learn how GMP converts a string to an array of 32bit words without wading through many layers of abstraction.</li>
  </ul>
  <h2>Examples Using 4 bit word size</h2>
  <p>Number we want to store (obviously on the small size): 123456789</p>
  <p>unsigned chars have a range of 0-255, if we want to split up our number and store it in the vector we can do it one of three ways:</p>
  <ul>
  <li>As base 10, our vector looks like: [1,2,3,4,5,6,7,8,9]
  <ul>
  <li>This is what my vector looked like in my first implementation.</li>
  </ul>
  </li>
  <li>As base 100, our vector looks like: [1,23,45,67,89]
  <ul>
  <li>Easy to convert from base 10 to base 100, has ciel(digits in base10/2) elements.</li>
  </ul>
  </li>
  <li>As base 256, our vector looks like: [7,91,205,21]</li>
  </ul>
  <p>Obviously the third solution is the most optimal for internal representation, and is what I am trying to get to.</p>