I have converted a mpz_int to gmp_int by converting a mpz_int to mpz_class
and then converting the mpz_class instance to a gmp_int.
Is there an easier way to do it ?
thanks
boost::multiprecision : How to convert a mpz_int variable to gmp_int?
1k Views Asked by user3664264 At
2
There are 2 best solutions below
1
On
For me, the convert_to<> method seems to work: Live On Coliru
#include <boost/multiprecision/mpfr.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
int main()
{
cpp_int i;
mpz_int z;
i = z.convert_to<cpp_int>();
}
From the tutorial and documentation, there is a member function
backend()inmpz_intthat gives access to the underlyinggmp_int.