You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NumericUpDown control is improperly parsing a decimal value that is entered with no leading zero in the en-US culture. For example, .1 becomes 1.0, 0.105 becomes 105, etc.
What steps will reproduce this issue?
This is a really easy issue to reproduce. An entire working example showing the failure is:
class Program
{
// The regex copy pasted out of numericupdown control file...
private static readonly Regex RegexStringFormatNumber = new Regex(@"[-+]?(?<![0-9][.,])\b[0-9]+(?:[.,\s][0-9]+)*[.,]?[0-9]?(?:[eE][-+]?[0-9]+)?\b(?!\.[0-9])", RegexOptions.Compiled);
static void Main(string[] args)
{
// returns 1
string leadingdec = GetAnyNumberFromText(".1");
// returns 0.1
string leadingZero = GetAnyNumberFromText("0.1");
// returns 0.1 in double
double.TryParse(".1", out double leadingDecDouble);
// also returns 0.1 in double
double.TryParse("0.1", out double leadingZeroDouble);
}
// The GetAnyNumberFromText function copy pasted out of numericupdown control file...
private static string GetAnyNumberFromText(string text)
{
var matches = RegexStringFormatNumber.Matches(text);
if (matches.Count > 0)
{
return matches[0].Value;
}
return text;
}
}
Expected outcome
We expect the parsed value to match the value that double.Parse would return on the raw string. For this example, ".1" should parse to 0.1 not 1.0 which it does currently.
Environment
MahApps.Metro: Latest master has issue
Windows OS 10
Visual Studio 2017
.NET Framework 4.5
The text was updated successfully, but these errors were encountered:
The NumericUpDown control is improperly parsing a decimal value that is entered with no leading zero in the en-US culture. For example, .1 becomes 1.0, 0.105 becomes 105, etc.
What steps will reproduce this issue?
This is a really easy issue to reproduce. An entire working example showing the failure is:
Expected outcome
We expect the parsed value to match the value that double.Parse would return on the raw string. For this example, ".1" should parse to 0.1 not 1.0 which it does currently.
Environment
The text was updated successfully, but these errors were encountered: