Skip to content

Commit 96f4562

Browse files
committed
Trailing zero
1 parent d1bfd03 commit 96f4562

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/libraries/System.Runtime.Numerics/src/System/Number.BigInteger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ static ParsingStatus DivideAndConquer(ref NumberBuffer number, out BigInteger re
10691069
currentBuffer = buffer.Slice(0, currentBufferSize);
10701070

10711071
trailingZeroBuffer = trailingZeroBuffer.Slice(0, currentTrailingZeroBufferLength);
1072-
if (trailingZeroBuffer.Length <= 1)
1072+
if (trailingZeroBuffer.Length <= 1 && currentBufferSize < buffer.Length)
10731073
{
10741074
Debug.Assert(trailingZeroBuffer.Length == 1);
10751075
uint trailingZero = trailingZeroBuffer[0];

src/libraries/System.Runtime.Numerics/tests/BigInteger/parse.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ private static void VerifyDefaultParse(Random random)
207207
VerifyParseToString(GetDigitSequence(100, 1000, random));
208208
}
209209

210+
// Trailing Zero
211+
VerifyParseToString("99000000000");
212+
for (int i = 0; i < s_samples; i++)
213+
{
214+
VerifyParseToString(GetDigitSequence(1, 10, random) + "1000000000");
215+
}
216+
210217
// Leading White
211218
for (int i = 0; i < s_samples; i++)
212219
{
@@ -464,6 +471,13 @@ private static void VerifyNumberStyles(NumberStyles ns, Random random)
464471
VerifyParseToString(GetDigitSequence(100, 1000, random), ns, true);
465472
}
466473

474+
// Trailing Zero
475+
VerifyParseToString("99000000000", ns, true);
476+
for (int i = 0; i < s_samples; i++)
477+
{
478+
VerifyParseToString(GetDigitSequence(1, 10, random) + "1000000000", ns, true);
479+
}
480+
467481
// Leading White
468482
for (int i = 0; i < s_samples; i++)
469483
{

0 commit comments

Comments
 (0)