You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This does not add bitwise-or and bitwise-xor operations between signed integers and BigUint, because there is no good way to represent negative numbers with a BigUint (see #184). Bitwise-and operations were added because the result of such an operation will always be positive.
Bitwise-and operations were added because the result of such an operation will always be positive.
Just because we can, doesn't mean we should, and this would be the only operator that mixed BigUint with signed primitives.
(Well, except for shifts, but the standard library already set the precedent for that oddness...)
You're right; I hadn't realized that the other operations would have such an issue until after I'd written the BitAnd implementation, and I figured it'd be better to ask before deleting it. I'll happily do so now if it doesn't make sense to include.
Bitwise-and operations were added because the result of such an operation will always be positive
Correct me if I'm wrong, but ANDing -1 (as a BigInt) with any number (in two's complement) should be a no-op, therefore returning the original number with whatever sign it had before the operation. Does this library use another encoding other than two's complement? (sorry for this question, I'm new to Rust and this repo)
Update: wait I realized my mistake lol. The PR is about mixed-type bit ops, so a primitive -1 would have a finite popcount equal to its wordsize, therefore always returning an unsigned number
I still think the mixed signed-ness is too confusing, let's drop that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #205.
This does not add bitwise-or and bitwise-xor operations between signed integers and BigUint, because there is no good way to represent negative numbers with a BigUint (see #184). Bitwise-and operations were added because the result of such an operation will always be positive.