Skip to content

BigInteger correctness regression from .NET 8 #109669

@hez2010

Description

@hez2010

Description

BigInteger produces incorrect results in .NET 9, while this doesn't repro with .NET 8 or earlier.

Reproduction Steps

Console.WriteLine(new BigInteger(-4294967296) & new BigInteger(-1919810));
Console.WriteLine(new BigInteger(-4042322161) & new BigInteger(-252645136));
Console.WriteLine(new BigInteger(-8589934592) | new BigInteger(-21474836480));

Console.WriteLine(BigInteger.Parse("-4294967296") & BigInteger.Parse("-1919810"));
Console.WriteLine(BigInteger.Parse("-4042322161") & BigInteger.Parse("-252645136"));
Console.WriteLine(BigInteger.Parse("-8589934592") | BigInteger.Parse("-21474836480"));

Expected behavior

-4294967296
-4294967296
-4294967296
-4294967296
-4294967296
-4294967296

Actual behavior

0
0
0
0
0
0

Regression?

Yes

Known Workarounds

No

Configuration

.NET 9 rc2

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions