clasp icon indicating copy to clipboard operation
clasp copied to clipboard

ldbxxx functions should be implemented using gmp

Open drmeister opened this issue 9 years ago • 3 comments

drmeister avatar Feb 08 '16 22:02 drmeister

@selwynsimsek is working on bignum stuff right now, but I thought I'd take a glance at this, and I don't actually see how to do it in any direct fashion.

What we do now is (ldb (byte size position) integer) = (logand (ash integer (- position)) (lognot (ash -1 size))), i.e., we lose the low bits then AND it with an appropriately sized mask. With bignums, from what I can see of GMP (https://gmplib.org/manual/Integer-Functions.html) we'd have to do the same thing. There's no specific way to extract a couple bits.

Bike avatar Apr 22 '20 14:04 Bike

though if we had access to the array of limbs directly, like selwyn was doing, we could just grab whatever limbs are covered by the position, i suppose. might save a few cycles that would be used ANDing irrelevant bits.

Bike avatar Jul 09 '20 02:07 Bike

Now that I have rewritten bignums this does seem more possible, as we can access the bignum "digits" directly. We can reduce or eliminate consing in some cases, though I don't know how much they come up.

Bike avatar Nov 05 '20 19:11 Bike