user3664264
user3664264

Reputation: 31

boost::multiprecision : How to convert a mpz_int variable to gmp_int?

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

Upvotes: 1

Views: 1149

Answers (2)

Marc Glisse
Marc Glisse

Reputation: 7915

From the tutorial and documentation, there is a member function backend() in mpz_int that gives access to the underlying gmp_int.

Upvotes: 2

sehe
sehe

Reputation: 392833

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>();
}

Upvotes: 0

Related Questions