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

Fix the unsigned right shift operator of BigInteger #112879

Merged
merged 4 commits into from
Feb 27, 2025

Conversation

kzrnm
Copy link
Contributor

@kzrnm kzrnm commented Feb 24, 2025

Fix #112564
Related #112878

Using BigInteger.GetPartsForBitManipulation will result in incorrect two's complement calculations for negative numbers where the most significant bit is set. For correct unsigned right shift, this method should not be used.

@tannergooding tannergooding merged commit 3e38bd8 into dotnet:main Feb 27, 2025
80 of 83 checks passed
@kzrnm kzrnm deleted the BigIntegerGetPartsForBitManipulation branch February 27, 2025 16:09
tannergooding pushed a commit that referenced this pull request Feb 27, 2025
* Add tests for the shift operator of BigInteger

* Fix the unsigned right shift operator of BigInteger

* avoid stackalloc

* external sign element
tannergooding pushed a commit that referenced this pull request Feb 27, 2025
* Add tests for the shift operator of BigInteger

* Fix the unsigned right shift operator of BigInteger

* avoid stackalloc

* external sign element
tannergooding pushed a commit that referenced this pull request Feb 27, 2025
* Add tests for the shift operator of BigInteger

* Fix the unsigned right shift operator of BigInteger

* avoid stackalloc

* external sign element
tannergooding pushed a commit that referenced this pull request Feb 27, 2025
* Add tests for the shift operator of BigInteger

* Fix the unsigned right shift operator of BigInteger

* avoid stackalloc

* external sign element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Numerics community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The unsigned right shift operator (>>>) of BigInteger behaves strangely
2 participants