Skip to content

Feature request: BigInteger.getBits #7

Description

@danwallach

Right now, there are primitive methods to get and set individual bits. It would be handy for my use case (accelerating modular exponentiation for bases that are frequently reused, like a generator) to be able to fetch multiple bits at once.

While a general purpose version of this would be equivalent to shifting right, masking, and returning another BigInteger, the algorithm I'm using only needs to digest somewhere between 8 and 16 bits at a time, so an API that returns a ULong or UInt would be perfect.

I could take a swing at building this for you, if you want, but I thought I'd see what you think about the idea first.

(I'm porting some code from Python that takes advantage of Gmpy's xmpz type, which has an operation equivalent to the getBits that I'm requesting. This particular acceleration is worth 10x performance with 4000 bit numbers.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions