将点后的位数设置为双倍 [英] Set the number of digits after the point in double
本文介绍了将点后的位数设置为双倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
在c#double类型中,如何设置点之后的位数,我只需要4.
谢谢。 / div>
你不能。 二进制浮点不工作。您可以以双重方式(例如使用f4
作为格式字符串)格式,但如果您正在处理具有自然数十进制,那么你应该可以使用 decimal
来代替。你能给我们更多关于你的价值观的信息吗?
In c# double type how can i set the number of digits after the point, i need only 4. thank you.
解决方案
You can't. Binary floating point doesn't work like that. You can format a double that way (e.g. using "f4"
as the format string), but if you're dealing with values which have a natural number of decimal places, then you should probably be using decimal
instead. Could you give us more information about what your values represent?
这篇关于将点后的位数设置为双倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文