converting from GMP to QD
Décio Luiz Gazzoni Filho
decio at decpp.net
Wed Aug 1 16:03:44 CEST 2012
On Aug 1, 2012, at 2:16 AM, Marc Glisse <marc.glisse at inria.fr> wrote:
> 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.
>
Another suggestion would be to export to a string in base 16 since that doesn't require an explicit calculation, as converting to base 10 would. That's assuming that QD is capable of parsing base-16 integers.
Décio
> --
> Marc Glisse
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
More information about the gmp-discuss
mailing list