Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private BigInteger(Span<uint> value)

if ((length == 0) || ((int)value[length - 1] >= 0))
{
// We ne need to preserve the sign bit
// We need to preserve the sign bit
length++;
}
Debug.Assert((int)value[length - 1] < 0);
Expand Down
16 changes: 16 additions & 0 deletions src/libraries/System.Runtime.Numerics/tests/BigInteger/op_and.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ public static void RunAndTests()
}
}

[Fact]
public void Issue109669()
{
// Operations on numbers whose result is of the form 0xFFFFFFFF 00000000 ... 00000000
// in two's complement.

Assert.Equal(-4294967296, new BigInteger(-4294967296) & new BigInteger(-1919810));
Assert.Equal(-4294967296, new BigInteger(-4042322161) & new BigInteger(-252645136));
Assert.Equal(-4294967296, new BigInteger(-8589934592) | new BigInteger(-21474836480));

BigInteger a = new BigInteger(MemoryMarshal.AsBytes([uint.MaxValue, 0u, 0u]), isBigEndian: true);
Assert.Equal(a, a & a);
Assert.Equal(a, a | a);
Assert.Equal(a, a ^ 0);
}

[Fact]
public static void RunAndTestsForSampleSet1()
{
Expand Down