Im working on one of a PIC24F series microcontroller to calculate distance between two latitude and longitude cordinates. I've included "math.h" header file for PIC24F in the code. The problem is acos(1) gives "0.000345" value, but im expecting "0.000086". The same code i've worked in eclipse by using eclipse's math.h header file, it give correct value "0.000086". What is the problem? Is "acos()" differ for each math.h header file?
.....
theta = lon1 - lon2;
printf("%f",theta);
dist = sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + cos(deg2rad(lat1)) * cos(deg2rad(lat2)) * cos(deg2rad(theta));
printf("%f", dist);
dist = acos(dist);
printf("%f", dist);
dist = rad2deg(dist);
printf("%f", dist);
.....
After passing the coordinates, the each "dist" variable value is below
Eclipse Output:
0.006082
1.000000
0.000086
0.004939
Microcontroller Output:
0.006088
1.000000
0.000345
0.019782
Thanks