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

Add setBit, clearBit and testBit #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

demotomohiro
Copy link

@demotomohiro demotomohiro commented Jul 12, 2022

This PR adds setBit, clearBit and testBit procs.
They are same to setBit, clearBit and testBit in std/bitops.

@konsumlamm
Copy link
Contributor

I like this, however I'd prefer if this could treat negative numbers as if they were represented in 2's complement, like in #111. For that, if the input is negative, set isNegative to false, decrement it (this is done by invertIn in #111, although it copies the BigInt first), then treat every bit as inverted (and the other bits that aren't stored as 1, so clearBit would then need to update the length, instead of setBit) and keep in mind that the updated bit also needs to be inverted. Then, at the end, increment, and set isNegative to true again (this is done by invertOut in #111).

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

Successfully merging this pull request may close these issues.

2 participants