mpz_init_setbit
marco.bodrato at tutanota.com
marco.bodrato at tutanota.com
Sat Feb 21 17:34:44 CET 2026
Ciao,
I think it would be useful to have yet another mpz_init_ function, do you mind if I add it?
void
mpz_init_setbit (mpz_ptr dest, mp_bitcnt_t bit_idx)
{
mp_ptr dp;
mp_size_t limb_idx = bit_idx / GMP_NUMB_BITS;
mp_limb_t mask = CNST_LIMB(1) << (bit_idx % GMP_NUMB_BITS);
ALLOC (dest) = SIZ (dest) = limb_idx + 1;
PTR (dest) = dp = __GMP_ALLOCATE_FUNC_LIMBS (limb_idx + 1);
MPN_ZERO (dp, limb_idx);
dp[limb_idx] = mask;
}
Ĝis,
mb
More information about the gmp-devel
mailing list