Skip to content

Commit f92dff4

Browse files
committed
Use BigInteger(ReadOnlySpan<uint> value, bool negative)
1 parent 456bf8e commit f92dff4

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,7 @@ private static ParsingStatus NumberToBigInteger(ref NumberBuffer number, out Big
364364
resultBuffer = resultBuffer.Slice(0, BigIntegerCalculator.ActualLength(resultBuffer));
365365
Debug.Assert(resultBuffer.Length == 0 || resultBuffer[^1] != 0);
366366

367-
result = resultBuffer.Length == 0
368-
? BigInteger.Zero
369-
: resultBuffer is [uint leading] && (leading <= int.MaxValue || number.IsNegative && leading == unchecked((uint)(int.MaxValue + 1)))
370-
? new BigInteger((int)(number.IsNegative ? -leading : leading))
371-
: new BigInteger(number.IsNegative ? -1 : 1, resultBuffer.ToArray());
367+
result = new BigInteger(resultBuffer, number.IsNegative);
372368

373369
if (resultBufferFromPool != null)
374370
ArrayPool<uint>.Shared.Return(resultBufferFromPool);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ internal BigInteger(int n, uint[]? rgu)
485485
/// </summary>
486486
/// <param name="value">The absolute value of the number</param>
487487
/// <param name="negative">The bool indicating the sign of the value.</param>
488-
private BigInteger(ReadOnlySpan<uint> value, bool negative)
488+
internal BigInteger(ReadOnlySpan<uint> value, bool negative)
489489
{
490490
if (value.Length > MaxLength)
491491
{

0 commit comments

Comments
 (0)