2011-09-15 36 views
5

我試圖讀取XML文件的一些數據,數字保存在形式,如「-2.000000e + 000」如何解析一些像「-2.000000e + 000」

我試圖用「 double.Parse「,但它返回的數字爲-2000000 !!!!有人能告訴我我做錯了什麼嗎?

+3

可能的複製http://stackoverflow.com/questions/64639/convert-from-scientific-notation-string-to-float-in-c ? – AlG

+1

和這一個http://stackoverflow.com/questions/3879463/c-parse-a-number-from-exponential-notation – Samich

+1

你可能也想看看這個問題:http://stackoverflow.com/questions/ 147801/best-way-to-parse-float – Michael

回答

9

通行證CultureInfo.InvariantCulture號召,double.Parse:中

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

+1是的,正確的答案 –

+0

Thaaaaaanks你救了我的一天! –