Remove E sign from big float number , C#?

2020-07-14 12:11发布

If you used big float numbers , you found in C# big float number is showed like this :
2000000 * 2000000 = 4E+12

How can I show 4E+12 as 4,000,000,000,000 not 4E+12 ?

2条回答
够拽才男人
2楼-- · 2020-07-14 12:50

Really great answer!

My code is

Double dblAcct = (Double)childRow["Account No"];
s_acct = dblAcct.ToString("F0");
s_acct = s_acct.PadLeft(16, '0');
查看更多
虎瘦雄心在
3楼-- · 2020-07-14 12:58

You want

number.ToString("N0");

"N0" is Number with no decimal places.

The alternative - "F0" is Fixed-point with no decimal places but prints without the comma separators:

double number = 4e12;
Console.WriteLine(number.ToString("F0"));
Console.WriteLine(number.ToString("N0"));

prints:

4000000000000
4,000,000,000,000

Source

查看更多
登录 后发表回答