1

I get a double value after certain calculation as 1084218256710914.2

When I convert it to string, it gives me value in some format which contains E i.e exponential part.

I tried string.Format("{0:F8}", value);

which gave me "1,084,218,256,710,910.00000000" as I want max 8 digits after decimal points.

I want output like this "1084218256710914.2"

Can anyone please help me with it?

Mayur Mohite
  • 41
  • 1
  • 9
  • Possible duplicate of [How to convert double to string without the power to 10 representation (E-05)](http://stackoverflow.com/questions/1319191/how-to-convert-double-to-string-without-the-power-to-10-representation-e-05) – Hernan Guzman Feb 12 '16 at 04:20
  • I have tried that but the problem is it resets everything after decimal point as you can see the values I've given. It ends with 914.2 but after conversion it's 910.0. I want the values after decimal points as well – Mayur Mohite Feb 12 '16 at 04:26
  • 2
    use "R" as format string. Please see http://stackoverflow.com/questions/611552/c-sharp-converting-20-digit-precision-double-to-string-and-back-again – bkdev Feb 12 '16 at 05:10
  • Even R worked like G17 – Mayur Mohite Feb 12 '16 at 06:02

1 Answers1

2

value.ToString("G17"); should do the trick.

KayGee
  • 93
  • 6