[1480] in Athena Bugs
No subject found in mail header
daemon@ATHENA.MIT.EDU (tykao@ATHENA.MIT.EDU)
Tue Dec 6 13:32:04 1988
From: <tykao@ATHENA.MIT.EDU>
To: <bugs@ATHENA.MIT.EDU>
In-Reply-To: Your message of Mon, 05 Dec 88 15:31:59 -0500.
Date: Tue, 06 Dec 88 13:08:02 EST
I was having problems on the vax workstations while I was working in
building 11. I am not sure what type of processor it was.
Here is the source of the program. It comes with nine data files.
If you need them send me mail.
The error message merely says Illegal instruction while processing the
data in the second datafile (I think). I will send that file along.
The error can be corrected by changing the statement sum = log(sum)/log(10)
to sum = log10(sum).
--------------------
#include<stdio.h>
#include<math.h>
main()
{
FILE *data, *result, *fopen();
char fname[9];
int number = 49;
int i = 0;
float x1, y1, x2, y2, sum, distance;
for (i = 0; i <= 8; i++)
{
number = 49 + i;
fname[0] = 'm';
fname[1] = 'i';
fname[2] = 'd';
fname[3] = number;
fname[4] = '.';
fname[5] = 'd';
fname[6] = 'a';
fname[7] = 't';
printf ("%s\n", fname);
if ((data = fopen(fname, "r")) == NULL)
{
fprintf (stderr, "Can't find %s\n", fname);
exit(1);
}
sum = 0.0;
distance = 0.0;
fscanf (data, "%f %f", &x1, &y1);
while ((fscanf(data, "%f %f", &x2, &y2)) != EOF)
{
distance = pow((x2 - x1), 2.0) + pow((y2 - y1), 2.0);
sum = sum + pow(distance, 0.5);
x1 = x2;
y1 = y2;
}
printf ("sum %f\n", sum);
sum = log(sum)/log(10);
printf ( "%f\n", sum);
fclose (data);
}
}
---------------------
The following is the data file named mid2.dat
------------------
0.000000 0.000000
0.250000 -0.015715
0.500000 -0.414984
0.750000 -0.594712
1.000000 -0.581518