Truncating decimal points

  • Thread starter Thread starter prakashdehury
  • Start date Start date
P

prakashdehury

can some one pls suggest me why?

StreamWriter sw = new StreamWriter(@"c:\Temp\1.txt");
double dd1;
double dd2;
double dd3;
double dd4;
dd1 = 1452.123456789876123456;
dd2 = 1452.123456789123123456;
dd3 = 1452.123456789567123456;
dd4 = 1452.123456789456123456;

sw.WriteLine(dd1.ToString());
sw.WriteLine(dd2.ToString("G"));
sw.WriteLine(dd3);
sw.WriteLine(dd4);
sw.Close();


Output
----------
1452.12345678988
1452.12345678912
1452.12345678957
1452.12345678946


why it round off the values to 11 decimal places?

Thanks
Prakash
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top