I’m trying to convert a string to a double value in .Net 3.5. Quite easy so far with
double.Parse(value);
My problem is that values with exponential tags are not right converted.
Example:
double value = double.Parse("8.493151E-2");
The value should be = 0.0893151 right?
But it isn’t!
The value is = 84931.51!!!
How can that be?
I’m totally confused!
I read the reference in the msdn library and it confirms that values like “8.493151E-2” are supported. I also tried overloads of double.Parse() with NumberStyles, but no success.
Please help!
It works for me:
You’re probably running in a locale that uses
,for the decimal separator and.for the thousands separator.Therefore, it’s being treated as
8,493,151E-2, which is in fact equivalent to84,931.51.Change it to