Single.TryParse methods rounds values


hello,
i experiencing unexpected rounding while converting string single. here code snippet shows problem:
  string s = "9999,9999";    single f;    single.tryparse(s, out f);  
in case, converted value (f variable) holds 10000 intead of 9999,9999 expected.
if use decimal, intead of single, expected result. however, know why float (or single) not support convertion , why rounding took place. had problems figure out rounding hapenning....
i read @ msdn docs, float has 7-digit precision. in understanding, means 7 "decimal digits", right? in case, using 4.
could please clarify issue me?
sincerely,
igor.

software developer business applications www.twitter.com/ikondrasovas

precision indicates number of significant digits permitted.  have 8.  when parse occurs, round of final 9 occurs.  try using double.


Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

wcf-sql adapter bug for operation on same table

Error connecting to Azure Blob using Shared Access signature