Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFor
{
result = 0;
int i;
if (!Number.TryParseInt32(s, style, info, out i))
if (!Number.TryParseInt32(s, style, info, out i, out _))
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/System.Private.CoreLib/shared/System/Decimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,12 @@ public static bool TryParse(string s, out decimal result)
return false;
}

return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, out decimal result)
{
return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result, out _);
}

public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out decimal result)
Expand All @@ -506,13 +506,13 @@ public static bool TryParse(string s, NumberStyles style, IFormatProvider provid
return false;
}

return Number.TryParseDecimal(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseDecimal(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out decimal result)
{
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
return Number.TryParseDecimal(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseDecimal(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

// Returns a binary representation of a Decimal. The return value is an
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +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);
bool success = Number.TryParseDouble(s, style, info, out result, out _);
if (!success)
{
ReadOnlySpan<char> sTrim = s.Trim();
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Int16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFor
{
result = 0;
int i;
if (!Number.TryParseInt32(s, style, info, out i))
if (!Number.TryParseInt32(s, style, info, out i, out _))
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/System.Private.CoreLib/shared/System/Int32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ public static bool TryParse(string s, out int result)
return false;
}

return Number.TryParseInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, out int result)
{
return Number.TryParseInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result, out _);
}

// Parses an integer from a String in the given style. Returns false rather
Expand All @@ -173,13 +173,13 @@ public static bool TryParse(string s, NumberStyles style, IFormatProvider provid
return false;
}

return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out int result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

//
Expand Down
8 changes: 4 additions & 4 deletions src/System.Private.CoreLib/shared/System/Int64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ public static bool TryParse(string s, out long result)
return false;
}

return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, out long result)
{
return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result, out _);
}

public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out long result)
Expand All @@ -161,13 +161,13 @@ public static bool TryParse(string s, NumberStyles style, IFormatProvider provid
return false;
}

return Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out long result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
return Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result);
return Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result, out _);
}

//
Expand Down
25 changes: 13 additions & 12 deletions src/System.Private.CoreLib/shared/System/Number.Dragon4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Internal.Runtime.CompilerServices;

namespace System
{
internal static partial class Number
{
private static unsafe void Dragon4(double value, int precision, ref NumberBuffer number)
{
const double Log10V2 = 0.30102999566398119521373889472449;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were moved out of the NumberBuffer.cs file because they are only used by Dragon4


// DriftFactor = 1 - Log10V2 - epsilon (a small number account for drift of floating point multiplication)
const double DriftFactor = 0.69;

// ========================================================================================================================================
// This implementation is based on the paper: https://www.cs.indiana.edu/~dyb/pubs/FP-Printing-PLDI96.pdf
// Besides the paper, some of the code and ideas are modified from http://www.ryanjuckett.com/programming/printing-floating-point-numbers/
Expand Down Expand Up @@ -149,7 +150,7 @@ private static unsafe void Dragon4(double value, int precision, ref NumberBuffer
r.Multiply10();
}

number.scale = (k - 1);
number.Scale = (k - 1);

// This the prerequisite of calling BigInteger.HeuristicDivide().
BigInteger.PrepareHeuristicDivide(ref r, ref s);
Expand All @@ -171,7 +172,7 @@ private static unsafe void Dragon4(double value, int precision, ref NumberBuffer
break;
}

number.digits[digitsNum] = (char)('0' + currentDigit);
number.Digits[digitsNum] = (char)('0' + currentDigit);
digitsNum++;

r.Multiply10();
Expand Down Expand Up @@ -199,7 +200,7 @@ private static unsafe void Dragon4(double value, int precision, ref NumberBuffer

if (isRoundDown)
{
number.digits[digitsNum] = (char)('0' + currentDigit);
number.Digits[digitsNum] = (char)('0' + currentDigit);
digitsNum++;
}
else
Expand All @@ -218,7 +219,7 @@ private static unsafe void Dragon4(double value, int precision, ref NumberBuffer
// Output 1 at the next highest exponent
*pCurrentDigit = '1';
digitsNum++;
number.scale += 1;
number.Scale += 1;
break;
}

Expand All @@ -244,14 +245,14 @@ private static unsafe void Dragon4(double value, int precision, ref NumberBuffer

while (digitsNum < precision)
{
number.digits[digitsNum] = '0';
number.Digits[digitsNum] = '0';
digitsNum++;
}

number.digits[precision] = '\0';
number.Digits[precision] = '\0';

number.scale++;
number.sign = double.IsNegative(value);
number.Scale++;
number.Sign = double.IsNegative(value);
}
}
}
Loading