2013-10-31 28 views
-1

我曾嘗試:轉換到非指數形式

MessageBox.Show(System.Numerics.BigInteger.Parse("7.56e+011", 
      NumberStyles.Float, 
      CultureInfo.InvariantCulture)); 

但它繼續顯示7.56e + 011

+1

這段代碼甚至不會編譯。在末尾添加'ToString()',你將在'num'中得到'756000000000'的值。 –

+0

@Lloyd'BigInteger.Parse(「7.56e + 011」,NumberStyles.Float,CultureInfo.InvariantCulture).ToString()'返回'756000000000' –

+0

@IlyaIvanov添加ToString()給出相同的輸出 – kr13

回答

2

您正在尋找格式編號。您可以使用String.Format這樣做

string.Format("{0:F}",System.Numerics.BigInteger.Parse("7.56e+011", 
      NumberStyles.Float, 
      CultureInfo.InvariantCulture)) 

運行下面的代碼

Code in VS2012

爲您提供以下的MessageBox

MessageBox with string

,你可以通過改變它沒有指定小數點格式爲{0:F0}

+0

它沒有工作 – kr13

+1

是的。我會告訴你證明 – Harrison

+0

@ kr13請看我的編輯。這表明它使用的MessageBox,你說你需要它在 – Harrison

0
decimal dec = decimal.Parse("7.7583877127496407E-6", 
    System.Globalization.NumberStyles.Any); 
    Console.WriteLine(dec); 
0

嘗試

BigInteger num = System.Numerics.BigInteger.Parse("7.56e+011", 
     NumberStyles.Float, 
     CultureInfo.InvariantCulture); 

String text = num.ToString("F5"); // New format string, here with 5 digits. 

您的解決方案呢從BigInteger再次隱式轉換回字符串,如果指數很大,則使用科學記數法。

+0

它不會編譯。 「無法從BigInteger轉換爲字符串」 – kr13

+0

???爲我完美工作。我看不到這會試圖暗示演員。 – PMF