I shouldn't post after just waking up. Man I have troubles even comprehending such a value. Maybe someone can shed some light on this. The only thing I found is:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedeflong big_int;//this wont work for 20million DIGITS...but
//hypothetically you could convert a character string into a large number
int main()
{
//8 bits is one byte under most systems
//so sizeof(big_int) = xbytes
//x bytes * 8 = number_of_bits
//therefore max number = 2^number_of_bits-1
//size = max_number+1;//...
const big_int SIZE = (big_int)ceil(powf(2, sizeof(big_int)*8));// replace with 20000000;
unsignedchar* pDigits = 0;
pDigits = newunsignedchar[SIZE];
//check if 20,000,000 bytes is allocated
if(!pDigits)
{
//throw assertion, if the following is false, the program will abort() or exit()
assert( pDigits && "Too Large OR Out of Memory, Failed to Allocate pDigitString" );
}
//remember that each element of pDigitString has a weighted (positional) significance.
big_int number = 0; //hypothetical big number
//this only works if each cell is between 0 and 255 (256 digits), limit of unsigned char datatype
//i'm not 100 percent sure this code is right, but I am sure it is possible in theory
//to store a large number
for(int pos = 0; pos < SIZE; pos++)
{
//slow as weight gets larget and larger
number = number + (big_int)pDigits[pos]*(big_int)floor(powf(2,pos));
}
//if this is ever reached
for(big_int pos = 0; pos < SIZE; pos++)
{
//slow as weight gets larger and larger
printf("number[%d] = %c\n", pos, pDigits[pos] );
}
delete [] pDigits;
pDigits = 0;
return 0;
}
@DeXipher
A pro library like the one linked to above is best, however if you're asking about "rolling your own" then see this old lounge thread in which Douas hosted a bigNum challenge. There were 5 entrants so there are 5 rather unique solutions to examine there.
http://www.cplusplus.com/forum/lounge/32041/