want fast bit set/extract
tg at swox.com
Mon Apr 26 03:41:02 CEST 2004
Kevin Ryde <user42 at zip.com.au> writes:
"D. J. Bernstein" <djb at cr.yp.to> writes:
> void mpz_copybits_fdiv(
> mpz_t rop,unsigned long t,
> mpz_t op,unsigned long s,
> unsigned long b)
Yes, something like that. I guess block set and clear would also be
of value. I'll add something to the tasks list if Torbjorn has no
I don't have any objections.
Instead of having an overly general function, we might want to
add two or three easy-to-understand functions. Alternatively,
have a general function and a few macros invoking the general
function in clever ways.
> An mpz_copybits_tdiv---which would be faster for negative numbers, and
> simpler, with your current integer representation---would be fine for
> typical applications. I suggested fdiv above because you seem to have
> mpz_tstbit = mpz_tstbit_fdiv, etc., without tdiv versions.
Yes, "emulated" twos-complement is the convention on the bitwise
things. Though it's a bit like hard work, and I'm not even sure if it
finds much genuine use. (There must have been a good reason it was
adopted in the first place, but I don't know what it was :-).
I did it like that because one gets well-defined semantics for
negative operands that way.
More information about the gmp-discuss