如何从指数符号中删除零 [英] how can I remove zeros from exponent notation
本文介绍了如何从指数符号中删除零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 C# 中使用指数格式来格式化十进制数.例如如果数字是
I'm using exponential formatting to format a decimal number in C#. For example if the number is
0.0001234567
用
(0.0000123456).ToString("E4");
演出
1.2345E-004
如何从指数中删除前导零,使其显示如下?
How can I remove leading zero from exponent so it read as below?
1.2345E-4
推荐答案
假设你需要总是显示小数点后 4 位数字,试试
Assuming you need to always show 4 digits after decimal point, try
"0.0000E+0"
所以它会显示
(0.0000123456).ToString("0.0000E+0"); //1.2345E-5
(0.0000120000).ToString("0.#E+0"); //1.2000E-5
如果您不需要显示小数点后的 4 位数字,请使用
if you don't need to show 4 digits after decimal points use
"0.#E+0"
所以它会显示
(0.0000123456).ToString("0.#E+0"); //1.2E-5
(0.0000120000).ToString("0.#E+0"); //1.2E-5
这篇关于如何从指数符号中删除零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文