更新时间:2023-11-28 23:47:34
双打不能完全重新present 16.9。我建议你将其转换为十进制
来代替:
Doubles can't exactly represent 16.9. I suggest you convert it to decimal
instead:
string s = "16.9";
decimal m = Decimal.Parse(s) * 100;
double d = (double)m;
您可能只是想继续使用十进制
而不是双
,既然你说你会使用它的金融需求。请记住,十进制
是为了准确地再适合在precision present十进制数,而双
只能完全重新的做present二进制数。
You might just want to keep using the decimal
instead of the double
, since you say you'll be using it for monetary purposes. Remember that decimal
is intended to exactly represent decimal numbers that fit in its precision, while double
will only exactly represent binary numbers that do.