c#string to float conversion无效?

pun*_*ter 1 c# floating-point type-conversion floating-accuracy

var x = dr["NationalTotal"].ToString();
Run Code Online (Sandbox Code Playgroud)

给了我333333333

var xxx = Convert.ToSingle(dr["NationalTotal"].ToString());
Run Code Online (Sandbox Code Playgroud)

给了我333333344

有什么想法吗?

SLa*_*aks 6

发生这种情况是因为Single没有足够的精度来存储您的完整数字.

Double 更精确.