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
{{ message }}
Repository navigation
Incorrect results of right shifting huge BigIntegers #65633
What OS and version, and what distro if applicable?
Windows 11 Pro Version 21H2
What is the architecture (x64, x86, ARM, ARM64)?
x64
Other information
Positive BigIntegers seem to not suffer from this issue, even if they are as enormous: (new BigInteger(1) << int.MaxValue) >> 1 seems to give expected results.
Slightly less enormous negative BigIntegers also seem to not suffer from this issue: (new BigInteger(-1) << (int.MaxValue - 1000)) >> 1 seems to give expected results. (new BigInteger(-1) << (int.MaxValue - 10)) >> 1, however, still returns -1.
How much we right shift the enormous big integer does not seem to affect the result. (new BigInteger(-1) << int.MaxValue) >> (int.MaxValue - 4) still gives -1.
@tannergooding Do you think this bug can be fixed without the significant refactoring we've been talking about for BigInteger, or should we wait to address it until we have that work scheduled?
Yes, it should be. It would probably be easier after, but I don't think that its necessary or good to wait if someone has time to look at this for .NET 7
Per discussion with the team, we will consider backporting the fix for this issue into .NET 6 if we can get validation that the user's scenario is addressed with the fix. We'd also need to get information that describes the types of applications affected, if the issues are blocking production scenarios, and an understanding of when .NET 7 would be adopted into that environment.
Per discussion with the team, we will consider backporting the fix for this issue into .NET 6 if we can get validation that the user's scenario is addressed with the fix. We'd also need to get information that describes the types of applications affected, if the issues are blocking production scenarios, and an understanding of when .NET 7 would be adopted into that environment.
I am sorry for my late reply.
But no, this doesn't block any production scenarios. I hit this issue when I was trying to self-educate by implementing a program that would compute lots of digits of pi. This has never been intended to be used in production and even for this purpose I don't need this functionality.
Reacted by Drew Kersnar
ghost locked as resolved and limited conversation to collaborators on Jun 9, 2022
Activity
jeffhandley commentedon Mar 30, 2022
@tannergooding Do you think this bug can be fixed without the significant refactoring we've been talking about for BigInteger, or should we wait to address it until we have that work scheduled?
tannergooding commentedon Mar 31, 2022
Yes, it should be. It would probably be easier after, but I don't think that its necessary or good to wait if someone has time to look at this for .NET 7
Fix dotnet#65633, multiplication overflow causing incorrect right shi…
Add unit test reproducing incorrect right shift results for BigInteger (
jeffhandley commentedon Apr 11, 2022
Per discussion with the team, we will consider backporting the fix for this issue into .NET 6 if we can get validation that the user's scenario is addressed with the fix. We'd also need to get information that describes the types of applications affected, if the issues are blocking production scenarios, and an understanding of when .NET 7 would be adopted into that environment.
Fix incorrect results of right shifting huge BigIntegers error report…
Fix incorrect results of right shifting huge BigIntegers error report…
gaazkam commentedon May 10, 2022
I am sorry for my late reply.
But no, this doesn't block any production scenarios. I hit this issue when I was trying to self-educate by implementing a program that would compute lots of digits of pi. This has never been intended to be used in production and even for this purpose I don't need this functionality.