summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System/Single.cs
diff options
context:
space:
mode:
authorTanner Gooding <tagoo@outlook.com>2018-10-29 11:15:35 -0700
committerGitHub <noreply@github.com>2018-10-29 11:15:35 -0700
commitaef0bc27daebb70ccc4bdb9bd46960b7e8b5eb0e (patch)
treeb103385ada8c66292dedfb4934638bb187cfeb80 /src/System.Private.CoreLib/shared/System/Single.cs
parentb1c22db881b1936ed37a798804c81ce7abc23b8e (diff)
downloadcoreclr-aef0bc27daebb70ccc4bdb9bd46960b7e8b5eb0e.tar.gz
coreclr-aef0bc27daebb70ccc4bdb9bd46960b7e8b5eb0e.tar.bz2
coreclr-aef0bc27daebb70ccc4bdb9bd46960b7e8b5eb0e.zip
Some cleanup of the System.Number class (#20619)
* Formatting Number.Formatting.cs and Number.Parsing.cs * Removing some duplicated parsing code by having the Parse method call TryParse * Moving two constants from NumberBuffer to Dragon4 * Rename FloatPrecision to SinglePrecision * Updating the casing of the NumberBuffer fields * Updating NumberBuffer to allow taking a custom-sized digit buffer. * Updating the various NumberBufferLength constants to be the exact needed lengths * Fixing DoubleNumberBufferLength and SingleNumberBufferLength to account for the rounding digit. * Fixing TryParseNumber to use the correct maxDigCount * Ensure the TryParseSingle out result is assigned on success
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Single.cs')
-rw-r--r--src/System.Private.CoreLib/shared/System/Single.cs23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Single.cs b/src/System.Private.CoreLib/shared/System/Single.cs
index 8d1788f731..dfe1af3f8c 100644
--- a/src/System.Private.CoreLib/shared/System/Single.cs
+++ b/src/System.Private.CoreLib/shared/System/Single.cs
@@ -330,28 +330,7 @@ namespace System
private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFormatInfo info, out float result)
{
- bool success = Number.TryParseSingle(s, style, info, out result);
- 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.TryParseSingle(s, style, info, out result, out _);
}
//