Remove E sign from big float number , C#?

孤人 提交于 2019-12-06 03:37:15

问题


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 ?


回答1:


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




回答2:


Really great answer!

My code is

Double dblAcct = (Double)childRow["Account No"];
s_acct = dblAcct.ToString("F0");
s_acct = s_acct.PadLeft(16, '0');


来源:https://stackoverflow.com/questions/4423054/remove-e-sign-from-big-float-number-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!