title: C# double to decimal precision loss
body: <p>I have a double <code>"138630.78380386264"</code> and I want to convert it to a decimal, however when I do so I do it either by casting or by using <code>Convert.ToDecimal()</code> and I lose precision.</p>
  
  <p>What's going on? Both decimal and double can hold this number:</p>
  
  <p><img src="https://i.stack.imgur.com/L0xyH.png" alt="enter image description here"></p>
  
  <pre><code>double doub = double.Parse("138630.78380386264");
  decimal dec = decimal.Parse("138630.78380386264");
  string decs = dec.ToString("F17");
  string doubse =DoubleConverter.ToExactString(doub);
  string doubs = doub.ToString("F17");
  
  decimal decC = (decimal) doub;
  string doudeccs = decC.ToString("F17");
  decimal decConv = Convert.ToDecimal(doub);
  string doudecs = decConv.ToString("F17");
  </code></pre>
  
  <p>Also: how can I get the <code>ToString()</code> on double to print out the same result as the debugger shows? e.g. <code>138630.78380386264</code>?</p>