Skip to content

Commit

Permalink
Fix Span length in TryFormatUInt64Slow (dotnet#34840)
Browse files Browse the repository at this point in the history
* Make the Span length right

* Adding a regression test for the span problem

* Avoid dependency on machine locale

* Using customFormat
  • Loading branch information
cshung authored Apr 15, 2020
1 parent 2eef5a3 commit bbc65f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ static unsafe bool TryFormatUInt64Slow(ulong value, ReadOnlySpan<char> format, I
NumberFormatInfo info = NumberFormatInfo.GetInstance(provider);

byte* pDigits = stackalloc byte[UInt64NumberBufferLength];
NumberBuffer number = new NumberBuffer(NumberBufferKind.Integer, pDigits, UInt32NumberBufferLength);
NumberBuffer number = new NumberBuffer(NumberBufferKind.Integer, pDigits, UInt64NumberBufferLength);

UInt64ToNumber(value, ref number);

Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/tests/System/UInt64Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static IEnumerable<object[]> ToString_TestData()
yield return new object[] { (ulong)123, "E", customFormat, "1~230000E&002" };
yield return new object[] { (ulong)123, "F", customFormat, "123~00" };
yield return new object[] { (ulong)123, "P", customFormat, "12,300.00000 @" };
yield return new object[] { ulong.MaxValue, "n5", customFormat, "18*446*744*073*709*551*615~00000" };
}

[Theory]
Expand Down

0 comments on commit bbc65f5

Please sign in to comment.