GMP is designed to have arbitrary precision with support for C++ using the gmpxx.h
header, and corresponding library. If you're building GMP from scratch, use --enable-cxx
flag during configure.
To construct an object from std::string
, simply use the constructor, for example,
#include <gmpxx.h>
const std::string longNumber = "12345678901234567890";
mpz_class n(longNumber);
More details are available here