converting from GMP to QD

Marc Glisse marc.glisse at inria.fr
Wed Aug 1 07:16:15 CEST 2012


On Tue, 31 Jul 2012, Pasquale Tricarico wrote:

> Hi,
>
> I am currently using both GMP and QD libraries, converting from mpz to
> dd_real using something like this:

Is QD documented anywhere?

>    dd_real mpzToDD(const mpz_class & z) {
>        char * str = (char *)malloc(mpz_sizeinbase(z.get_mpz_t(),10)+2);
>        mpz_get_str(str,10,z.get_mpz_t());
>        dd_real x(str);
>        free(str);
>        return x;
>    }

You know, z.get_str() would save you a bit of typing.

> I would be interested in knowing if there is a more efficient way to do this.

If QD documents the storage format of dd_real, you may be able to use 
mpz_export in some way.

-- 
Marc Glisse


More information about the gmp-discuss mailing list