C++ String to double atof conversion losing precision?
<p>C++ is not my language so forgive this simple problem. I'm losing precision in an atof conversion from string to double, can anyone help?</p>

<pre><code>string lAmount;

string lSuspendedInt = "131663.51";
string lAccruedInterest = "0.0";
double dSuspendedInt= atof(lSuspendedInt.c_str());   //PROBLEM HERE?
double dAccruedInterest = atof(lAccruedInterest.c_str());
double dTotal = dSuspendedInt + dAccruedInterest;

char cAmount[50];

memset(cAmount,0X00,sizeof(cAmount));
  sprintf(cAmount,"%g*",dTotal);
  lAmount = cAmount;


cout &lt;&lt; "lAmount: "&lt;&lt;lAmount&lt;&lt;endl; //PRINTING: 131664 not 131663.51
</code></pre>

<p>I've played with %f in the memset function however this gives 131663.510000</p>

<p>Thanks in advance.</p>

<p>Sapatos</p>
