mp_bitcnt_signed_t

Niels Möller nisse at lysator.liu.se
Sat Aug 22 17:26:48 UTC 2015


Vincent Lefevre <vincent at vinc17.net> writes:

> On 2015-08-22 14:21:55 +0200, Niels Möller wrote:
>> If it's really non-negative, I think I'd prefer the unsigned
>> mp_bitcnt_t. I don't think consistency with mpf (deprecated) is
>> important.
>
> Is there any reason to prefer an unsigned type?

Not sure, maybe on 32-bit systems the extra bit matters (if we want to
support mpz_t values with up to 2^32-1 bits; I don't remember the
documented limits). Or maybe it's a mistake that mp_bitcnt_t is unsigned
in the first place?

But I don't think it's a good idea to introduce mp_bitcnt_signed_t and
use it for a somewhat arbitrary subset of the GMP functions working with
bit counts.

> They are really ugly when doing arithmetic on them,

They have the slight advantage that behaviour on overflow is well
defined. But you might be right that problems from unexpected
conversions negate that advantage.

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