eln*_*h78 1 .net c# double rounding
我在C#中使用双数字有一个奇怪的问题.这里的NET是我的测试:
double my_value = 0.49;
问题是显示的变量值是0.48999999999999999我不需要显示0.49使用Math.Round()函数; 我需要准确存储这个值.
Math.Round()
谢谢.
Llo*_*oyd 5
欢迎来到浮点精度.decimal如果您想要更高的精度,请使用该类型.
decimal
decimal my_value = 0.49m;
如果你想了解更多为什么这是我建议你阅读这篇文章 - 每个计算机科学家应该知道浮点运算
归档时间:
12 年,3 月 前
查看次数:
308 次
最近记录: