title: manually printing a N-byte integer
body: <p>What is a scalable algorithm to print an N-binary-digit integer <em>manually</em> whose value does not fit in <code>long long</code>. I know <code>printf</code> and friends, along with <code>&lt;iostream&gt;</code> (which most likely piggy-backs on <code>&lt;cstdio&gt;</code> have this builtin for standard types, but I'd like to do it for an integer composed of N bytes.</p>
  
  <p>I have thought about this and googled a bit, but it always comes down to using a pre-existing bigint libirary like GMP (a codebase I am not at all familiar with) or "use printf" or the most helpful "this is difficult".</p>
  
  <p>The integer is basically:</p>
  
  <pre><code>template&lt;size_t N&gt;
  class Integer{
  ...
  private:
      int8_t first;
      uint8_t rest[N-1];
  }
  </code></pre>
  
  <p>so reinterpreting an <code>Integer&lt;4&gt;</code>'s bytes would get you an <code>int32_t</code>. I'd like to scale this to N>8. Efficiency is not really my concern at the moment. Neither is endianness (this is for x86).</p>