Dumbo
Dumbo

Reputation: 14122

How to parse a number like "-2.000000e+000"

I am trying to read some data from a xml file, numbers are saved in forms like "-2.000000e+000"

I tried to use "double.Parse" but it returns the number as -2000000!!!! can someone please tell me what I am doing wrong?

Upvotes: 5

Views: 1087

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174389

Pass CultureInfo.InvariantCulture to the call to double.Parse:

double.Parse("-2.000000e+000", CultureInfo.InvariantCulture);

Upvotes: 9

Related Questions