Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Double going to infinity... Could it be CultureInfo related?

Hi! I have this code on a Entry completion event:

if (double.TryParse(txt_MinRate.Text, out double i))
{
if (i < 0.0 || i > 6.0)
{
if (i > 6.0)
{
DisplayAlert("Invalid input", "6% is the maximum rate allowed.", "OK");
txt_MinRate.Text = "6.0";
}
else if (i < 0.0)
{
DisplayAlert("Invalid input", "Don't worry. There will never be a negative rate", "OH Good");
txt_MinRate.Text = "0.0";
}
}
else
{
Settings.MinRate = i / 100.0;
}
}

and the thing is... If I type 0.01 Settings.MinRate is saved with value 0.0001 which is what is expected to happen.

If I type 0.001 in the entry.... Settings.MinRate is saved with -Infinity.....

Can anyone explain what's going on here?

Sign In or Register to comment.