How to store a very large number in C ++
You can find your answer here How to store very large numbers? The GMP answer sounds right, i.e. this is what it does with pi digits https://gmplib.org/pi-with-gmp.html
source to share
You have to implement it yourself or use a library for this. In particular, I love GMP: https://gmplib.org/ , which is a C Big Int / Float implementation and has a C ++ wrapper
source to share
Use your class for your number, for example:
#include <vector>
#include <iostream>
class large_num {
private:
int digits; // The number of digits in the large number
std::vector<int> num; // The array with digits of the number.
public:
// Implement the constructor, destructor, helper functions etc.
}
For a very large number, just add each digit to the vector. For example, if a number, if 123456, you do num.pushback (); In this case, press all numbers 1,2, ... 6. This way you can store very large numbers.
source to share
You should try this http://sourceforge.net/projects/libbigint/
great library for such things.
also you can use boost.
http://www.boost.org/doc/libs/1_53_0/libs/multiprecision/doc/html/boost_multiprecision/intro.html
also one of the most common https://gmplib.org/
source to share