test if an unsigned long fits in a limb.
Niels Möller
nisse at lysator.liu.se
Wed Mar 7 09:25:21 CET 2012
Marc Glisse <marc.glisse at inria.fr> writes:
> Imagine that mpz_set_si takes as argument a long long on win64. I can
> still pass it a long with no problem. Imagine that mpz_get_si outputs
> a long long. I can still store it safely in a long, because I first
> called mpz_fits_slong_p to check that it would fit. It doesn't look
> like I have lost anything.
I see. That could work, even if I'm still not convinced it's a good idea
to have the type used depend on the GMP configuration. If the intention
is to get an integer of size matching a the native word size, no matter
which C type that may be, I think using mp_limb_t and mp_limb_signed_t
(but without nail bits) should be goood enough.
Functions using long long would provide additional functionality on
platforms where long long is larger than mp_limb_t (presumably because
long long is larger than the native word size). But I think those should
be additional functions, since they will give a larger overhead if you
really just want a long (which fits in a native word on sane platforms).
We can add an awful lot of functions here, so I imagine we need to think
a bit on which function really are needed. If I understand you
correctly, the most urgent problem is to be able to convert between
mpz_t and native (64-bit) integers on W64. Is there any other supported
platform that has chosen an ABI where "Long" is smaller than the native
word size?
Regards,
/Niels
--
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel
mailing list