-
Notifications
You must be signed in to change notification settings - Fork 245
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
Implementation of bitwise operations between BigInteger
#713
Conversation
in the unittests, any chance you could add some checks on the higher limbs (right now you're testing only on the least significant) and de morgan's law ? |
It's not clear to me that BigInteger should represent integers mod 2^(N*64), so I'm not ready to take responsability for supporting bitwise NOT in the API. I'm also not sure bitwise operations like >> and << should be treated differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now! A few notes copy-pasted from my commit message:
-
It's not clear to me that BigInteger should represent integers mod 2^(N*64), so I'm not ready to take responsability for supporting bitwise NOT in the API of BigInteger (it's however in BigInt)
-
I'm also not sure bitwise operations like >> should be treated differently. I think we should add support for Shr in the API and deprecate div2() and divn() perhaps in a different PR?
Can another maintainer can have a look at this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look safe to me. Shr and such would be nice (related) features and cleaning up any duplicated capability seems reasonable.
Thanks btw @hdvanegasm! |
Description
I implemented bitwise operations between BigInteger: AND, XOR, NOT, and OR. In the modifications, the trait BigInteger now implements the necessary traits to support the mentioned bitwise operations, and I included the implementations for those operations for the BigInt struct. Also, I wrote some tests for this functionality.
This PR doesn't close any issue. It's just a feature that I found missing in the library.