TryParse double confusion

So, I plunged into LinqPad and noticed something strange, I get the same result in the test code of the Visual Studio Unit Tests.

I played with all the different TryParse for numeric data types. During this, I noticed that double.TryParse acts a little differently than the rest.

For example:

var doubleStr = double.MinValue.ToString();
//doubleStr = -1.79769313486232E+308

double result;
var result = double.TryParse(doubleStr, out result);
//result is returning false

All other data types with MinValue do not have this problem:

var floatStr = float.MinValue.ToString();
//floatStr = -3.402823E+38 

float result2;
float.TryParse(floatStr, out result2);
//result = True

Does any body know why double is the only one that is false to parse the string version of the MinValue property back to the actual double?

I do not see why this is different from the hand. Maybe I'm missing something.

+4
source share
1

, double, "R" (round-trip) format :

double.Parse(double.MinValue.ToString("R"))

, , - . double.MinValue , , , double. , .

+5

Source: https://habr.com/ru/post/1614808/


All Articles