test if an unsigned long fits in a limb.

Marc Glisse marc.glisse at inria.fr
Tue Mar 6 22:58:53 CET 2012


On Tue, 6 Mar 2012, Niels Möller wrote:

> Marc Glisse <marc.glisse at inria.fr> writes:
>
>> Note that mpir is replacing signed/unsigned long by two typedefs that
>> can be defined as (unsigned) long long on _LONG_LONG_LIMB platforms.
>> That works around the problem too...

(actually they don't seem to have released that yet, they are just 
experimenting)

> But the point of the _ui and _si functions, as I understand them, is to
> make it safe and easy to pass values between code using GMP and code
> which is unaware of GMP types.
>
> One can have alternative functions accepting mp_limb_t and
> mp_limb_signed_t, if one finds that useful. But for the above reason,
> advertising such functions as a substitute for the _ui and _si functions
> seems to totally miss the point.

Their main goal is to be able to interact with 64 bit integers on win64.

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.

-- 
Marc Glisse


More information about the gmp-devel mailing list