want fast bit set/extract
user42 at zip.com.au
Sun Apr 18 00:50:33 CEST 2004
"D. J. Bernstein" <djb at cr.yp.to> writes:
> I often want to compute floor(n/2^s) mod 2^b, given n,b,s.
Yep, there could be a place for a bit extract like that.
> Similarly, I often want to replace n with n + 2^s m. This should be
> extremely fast (assuming few carries)
Is that an actual addition, or just replacing some bits at position s?
For a replacement I guess a single general purpose routine doing n1
bits from pos1 copied to n2 bits at pos2 might cover all inserts and
For an add, we don't have much in the way of primitives for a
combination shift-and-add currently. Which need not prevent an mpz
routine being conceived, though it may not go at top speed initially.
> Please support these two operations! These are _much_ more useful than
> isolated right-shift/left-shift operations.
I expect both have their uses :).
More information about the gmp-discuss