Skip to content

Commit 5407108

Browse files
committed
Fix assertion
1 parent 19f1e34 commit 5407108

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.SquMul.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ internal const
160160
public static void Multiply(ReadOnlySpan<uint> left, ReadOnlySpan<uint> right, Span<uint> bits)
161161
{
162162
Debug.Assert(left.Length >= right.Length);
163-
Debug.Assert(bits.Length == left.Length + right.Length);
163+
Debug.Assert(bits.Length >= left.Length + right.Length);
164+
Debug.Assert(!bits.ContainsAnyExcept(0u));
164165

165166
if (left.Length - right.Length < 3)
166167
{
@@ -175,7 +176,8 @@ public static void Multiply(ReadOnlySpan<uint> left, ReadOnlySpan<uint> right, S
175176
private static void MultiplyFarLength(ReadOnlySpan<uint> left, ReadOnlySpan<uint> right, Span<uint> bits)
176177
{
177178
Debug.Assert(left.Length - right.Length >= 3);
178-
Debug.Assert(bits.Length == left.Length + right.Length);
179+
Debug.Assert(bits.Length >= left.Length + right.Length);
180+
Debug.Assert(!bits.ContainsAnyExcept(0u));
179181

180182
// Executes different algorithms for computing z = a * b
181183
// based on the actual length of b. If b is "small" enough
@@ -370,7 +372,8 @@ stackalloc uint[StackAllocThreshold]
370372
private static void MultiplyNearLength(ReadOnlySpan<uint> left, ReadOnlySpan<uint> right, Span<uint> bits)
371373
{
372374
Debug.Assert(left.Length - right.Length < 3);
373-
Debug.Assert(bits.Length == left.Length + right.Length);
375+
Debug.Assert(bits.Length >= left.Length + right.Length);
376+
Debug.Assert(!bits.ContainsAnyExcept(0u));
374377

375378
// Executes different algorithms for computing z = a * b
376379
// based on the actual length of b. If b is "small" enough

0 commit comments

Comments
 (0)