Skip to content

Right shift of specific BigInteger values is producing incorrect results #59509

@slozier

Description

@slozier

Description

In the following example we start off with -0x1ffffffff, left shift by 31 bits and then right shift by 31 bits. The expected result would be -0x1ffffffff but we're getting -0x100000001ffffffff.

BigInteger x = -8589934591;
BigInteger y = (x << 31) >> 31;

Debug.Assert(x == y);

Configuration

Running on .NET 6.0.100-rc.1.21458.32

Regression

This is a regression from .NET Framework/.NET Core/.NET 5.

Other information

Might be related to the fix in #54115

@tannergooding

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions