mpn_set_str_bits

Niels Möller nisse at lysator.liu.se
Wed Sep 30 17:37:21 UTC 2020


Marco Bodrato <bodrato at mail.dm.unipi.it> writes:

>   limb = (unsigned int) sp[sn] >> (bits - shift);

That's easier to read than what I proposed.

> Maybe the cast is unnecessary, because the C standard says that the
> left operand of a shift operation is always promoted to (unsigned) int
> if it is smaller, correct?

I think so, but it's a bit subtle, so I'd prefer the explicit cast.
Maybe worth a comment mentioning the problem case: mp_limb_t
== unsigned char, bits == 8, shift == 0

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list