Hey all,
So I am writing a scientific code and thus precision of the numbers I am dealing with is very important. I have a text file as follows containing coordinate data:
Code:
15.874010519682 15.874010519682 15.874010519682 0.77500000000000
5.0000000000000D-03
0.67184753150321 -9.0984212637474 -0.12308571224722
-7.5391320707008 -5.4421377882969 -3.6434474261884
-2.8072699927977 -0.27226324050591 0.83267141127818
-3.4804472086739 1.7404956860775 3.6298663735869
-6.1997156299320 -8.4300686752649 3.5753823495533
Now I wrote a function to read this data (ignoring the first two lines) and print it out, just so I knew that the code was working correctly. Upon read out I only get:
Code:
First Line Header: 15.874011 15.874011 15.874011 0.775000
Second Line Header: 5.0000000000000D-03
Coords:
0.671848 -9.098421 -0.123086
-7.539132 -5.442138 -3.643447
-2.807270 -0.272263 0.832671
Now this is substantial rounding that I need to get rid of. I am using long doubles and I thought the right format identifiers but nothing seems to be working (i.e. no matter what I change I keep getting the rounded numbers). Here is my code:
Code:
void getpoints(void)
{
if((fp=fopen("daugh.1001","r"))==NULL)
{
printf("Cannot open file \n");
exit(0);
}
fscanf(fp,"%Lf %Lf %Lf %Lf\n", &tmp1, &tmp2, &tmp3, &tmp4);
printf(" First Line Header: %Lf %Lf %Lf %Lf \n",tmp1,tmp2,tmp3,tmp4);
fgets(tmp, 25, fp);
printf(" Second Line Header: %s\n",tmp);
for (k=0;k<3;k++)
{
fscanf(fp,"%Lf %Lf %Lf \n", &x[k], &y[k], &z[k]);
}
printf("Coords:\n");
for (k=0;k<3;k++){
printf("%Lf %Lf %Lf \n", x[k], y[k], z[k]);
}
}
It's probably something simple... any help you could lend would be greatly appreciated!
Thanks!,
Paddon