Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bit-packed array may be also useful #1

Open
schveiguy opened this issue Aug 2, 2018 · 0 comments
Open

Bit-packed array may be also useful #1

schveiguy opened this issue Aug 2, 2018 · 0 comments

Comments

@schveiguy
Copy link

2^24 integers comes out to about 67MB of storage required.

The largest prime number here is 71_378_569.

If you have a bitset with the bits of the prime numbers set up to this value, then this fits into 9MB, and has instantaneous lookup vs. binary search (for checking if a number is prime).

Using core.bitop, you would get both mechanisms to test for prime numbers (and I believe it's an intrinsic), and using BitRange, you get a way to iterate them.

Just food for thought. Could go in a different module in this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant