可能重复: Round小数点后双至2显著图
Possible Duplicate: Round a double to 2 significant figures after decimal point
我知道有一个例子如何圆这种数字工厂。 但可能有人告诉我如何圆形双,得到的价值,我可以显示为 字符串,总是有2位小数?
I know that there is plant of examples how to round this kind numbers. But could someone show me how to round double, to get value that I can display as a String and ALWAYS have 2 decimal places?
您可以使用的String.Format(%2F,D)
,你的双会自动四舍五入。
You can use String.format("%.2f", d)
, your double will be rounded automatically.