I'm doing a program that has to read in a rather large number. Actually, there are 2 numbers that I want to read. One has 12 digits, and the other has 1000 digits. I'm stumped and don't know quite how to proceed. I thought of reading and storing each digit as a member of a vector. S0 1000 digits results in a vector of 1000 elements. Does anyone know a better way to store such large number? Any help is appreciated.

2. Thats where BigNum libraries come in
Google for bignum libraries for c++.

Miracl is a commonly used one

Shamus Software Limited - Home --> Miracl .

Best Regards
KKR

3. Reading into a vector is about all you can do. That's how all the arbitrary precision libraries handle large numbers internally, more or less (well, probably arrays, but it's the same idea). If you're concerned about space you can use a string and/or convert to base 256.

And as a fan of GNU I'll link to an alternative to the library listed above.

4. Thanks guys for the reply. Here's what I've worked on, and it seems to work. I will certainly check out those lib. I wonder if the bignum lib can be found in repo for ubuntu; this would be sweet of it does.
Code:
```int main()
{
using namespace std;
ifstream ifs;
string temp;
vector<string> string_vec;
vector<int> int_vec;
set<int,greater<int> > set_product;
int product = 0;
ifs.open("problem_8.txt");
while( getline(ifs , temp))
string_vec.push_back(temp);
for(int i = 0 ; i<string_vec.size();++i)
{
temp = *(string_vec.begin()+i);
for(int i = 0 ; i < temp.length() ; i++)
{
//  cout << temp[i];
int_vec.push_back(static_cast<int> (temp[i]) - 48 );
}
}
}```

5. Originally Posted by bernt
Reading into a vector is about all you can do. That's how all the arbitrary precision libraries handle large numbers internally, more or less (well, probably arrays, but it's the same idea). If you're concerned about space you can use a string and/or convert to base 256.
Not mine. Mine stores the value in base 4294967296 i.e. it's stored in an array of 32-bit ints, wasting nothing, and built for speed of manipulation.
It can be found on the useful classes section of my website. Some others work the same way.