0

Hello,

I need to convert manually string "6.812345678912345678912345678" to double (well, high-precision double i guess...).

Below is my code, which only converts the first 9 digits. After that it's all messed up. I really need to convert this long string to the same long number. How do I do this? Any suggestions will be very appreciated.

char inputstr[] = "6.8123456789123456789123456789";

double result1 = 0;

// part before the point

for(int i=0; i<1; i++)

{

result1 = (result1 * 10) + inputstr* - '0';
}*

double result2=0;

double temp;

int nDecimalDigits;

nDecimalDigits = 1;

//part after the point

for(int j=2; j<30; j++)

{

temp = inputstr[j] - '0';

nDecimalDigits *= 10;

temp /= nDecimalDigits;

result2 += temp;

}