Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fixing up the Double/Single parsing code to be correct #20707

Merged
merged 29 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
705d368
Don't normalize -0.0 to 0.0 when parsing
tannergooding Oct 29, 2018
380a9ed
Updating NumberBuffer to validate the constructor inputs
tannergooding Oct 29, 2018
79b5d48
Updating NumberToDouble to just get the precision
tannergooding Oct 29, 2018
92bfc26
Don't check for non-significant zero's in NumberToDouble
tannergooding Oct 29, 2018
f1e6c17
Updating Number.BigInteger to carry additional space for the worst-ca…
tannergooding Oct 29, 2018
b80353c
Removing some dead code from double.TryParse
tannergooding Oct 31, 2018
b1f4611
Updating NumberToDouble to use the RealParser implementation from Roslyn
tannergooding Oct 31, 2018
c48e9a8
Fixing TryNumberToDouble and TryNumberToSingle to apply the appropria…
tannergooding Oct 31, 2018
57c8bf8
Adding a fast path for double/single parsing when we have <= 15 digit…
tannergooding Oct 31, 2018
dcb6aac
Update NumberBuffer to also track whether any input digits past maxDi…
tannergooding Oct 31, 2018
06650be
Renaming NumberToFloatingPointBitsRoslyn to NumberToFloatingPointBits
tannergooding Oct 31, 2018
31357e2
Updating TryNumberToDouble and TryNumberToSingle to support Overflow …
tannergooding Oct 31, 2018
0b9861e
Fixing a Debug.Assert in TryParseNumber
tannergooding Oct 31, 2018
5d2c797
Fixing `DecimalNumberBufferLength` to 30
tannergooding Oct 31, 2018
24e30d3
Renaming NumberToFloatingPointBitsRoslyn to NumberToFloatingPointBits
tannergooding Nov 1, 2018
cd87e00
Clarifying the NumberBufferLength comments
tannergooding Nov 1, 2018
83a9738
Fixing TryNumberToDecimal to check the last digit in the buffer, if i…
tannergooding Nov 1, 2018
c71b906
Fix TryNumberToDecimal to not modify the value of p in the assert.
pentp Nov 1, 2018
c08f180
Disable some CoreFX tests due to the single/double/decimal parsing fixes
tannergooding Nov 1, 2018
b91d670
Updating NumberToFloatingPointBits to use single-precision arithmetic…
tannergooding Nov 2, 2018
c334277
Splitting the NumberToFloatingPointBits code into a fast and slow-pat…
tannergooding Nov 2, 2018
e7e939a
Ensure Roslyn is properly attributed.
tannergooding Nov 2, 2018
31719b9
Removing the 80-bit extended precision fast path for NumberToFloating…
tannergooding Nov 2, 2018
90b82d9
Fixing the double and single parser to ignore case for Infinity and NaN
tannergooding Nov 2, 2018
7cf4b92
Add a clarifying comment to Number.NumberToFloatingPointBits that the…
tannergooding Nov 5, 2018
5a3c053
Removing the remaining code that was used by the 80-bit extended prec…
tannergooding Nov 5, 2018
4af4a96
Adding a missing comma to the CoreFX.issues.json
tannergooding Nov 7, 2018
9f488ac
Remove licensing "glue" and re-release the Roslyn RealParser code und…
tannergooding Nov 7, 2018
f90e2ba
Some minor cleanup to the NumberToFloatingPointBits code.
tannergooding Nov 7, 2018
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
6 changes: 0 additions & 6 deletions src/System.Private.CoreLib/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3100,9 +3100,6 @@
<data name="Overflow_Decimal" xml:space="preserve">
<value>Value was either too large or too small for a Decimal.</value>
</data>
<data name="Overflow_Double" xml:space="preserve">
<value>Value was either too large or too small for a Double.</value>
</data>
<data name="Overflow_Duration" xml:space="preserve">
<value>The duration cannot be returned for TimeSpan.MinValue because the absolute value of TimeSpan.MinValue exceeds the value of TimeSpan.MaxValue.</value>
</data>
Expand All @@ -3124,9 +3121,6 @@
<data name="Overflow_SByte" xml:space="preserve">
<value>Value was either too large or too small for a signed byte.</value>
</data>
<data name="Overflow_Single" xml:space="preserve">
<value>Value was either too large or too small for a Single.</value>
</data>
<data name="Overflow_TimeSpanElementTooLarge" xml:space="preserve">
<value>The TimeSpan string '{0}' could not be parsed because at least one of the numeric components is out of range or contains too many digits.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Number.Formatting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Number.Grisu3.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Number.NumberBuffer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Number.NumberToDouble.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Number.NumberToFloatingPointBits.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Number.Parsing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\NullReferenceException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\ObjectDisposedException.cs" />
Expand Down
23 changes: 1 addition & 22 deletions src/System.Private.CoreLib/shared/System/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,7 @@ public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatPro

private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFormatInfo info, out double result)
{
bool success = Number.TryParseDouble(s, style, info, out result, out _);
if (!success)
{
ReadOnlySpan<char> sTrim = s.Trim();
if (sTrim.EqualsOrdinal(info.PositiveInfinitySymbol))
{
result = PositiveInfinity;
}
else if (sTrim.EqualsOrdinal(info.NegativeInfinitySymbol))
{
result = NegativeInfinity;
}
else if (sTrim.EqualsOrdinal(info.NaNSymbol))
{
result = NaN;
}
else
{
return false; // We really failed
}
}
return true;
return Number.TryParseDouble(s, style, info, out result);
}

//
Expand Down
Loading