unsigned long long conversion
Torbjorn Granlund
tege at swox.com
Thu Apr 7 18:51:42 CEST 2005
I'd write an assignment function something like this:
if (sizeof (xx) != sizeof (unsigned long))
{
unsigned long h = xx >> 32;
mpz_set_ui (foo, h);
mpz_mul_2exp (foo, foo, 32);
mpz_add_ui (foo, foo, (unsigned long) xx);
}
else
{
mpz_set_ui (foo, xx);
}
(The hard-wired 32 isn't too pretty. The "if (sizeof ...)" test
should make things work for 64-bit machines in spite of that.)
I have not tested the above code.
--
Torbjörn
More information about the gmp-discuss
mailing list