mpz_set_ld (set from long double)
Sisyphus
sisyphus1 at optusnet.com.au
Mon Jun 11 12:08:15 CEST 2007
Hi,
I was trying to come up with a simple and effective way of assigning a long
double to an mpz_t.
I thought:
First, assign the long double to a string buffer, ie:
sprintf(buffer, "%.0Lf", ld);
And then assign the string to the mpz_t:
mpz_init_set_str(my_mpz_t, buffer, 10);
AFAICT that's both simple and effective - but is there a smarter, less
computationally-intensive way of achieving the desired result ?
Cheers,
Rob
More information about the gmp-discuss
mailing list