ipaq3115
Active member
I'm converting a set of long GPS coordinates to doubles so that I can manipulate them. Everything seems to be working as it should except that there is an error or something when dividing the coordinate down so that the decimal lines up.
Here's the function I'm playing with
I split it up to divide by 10 at a time when I found out it wasn't converting the number correctly.
Here's an example of a latitude I'm putting into the function
-776591120
... and this is what it's printing
That third line is the problem. No idea where those numbers at the end are coming from and it throws everything else off. Is it possible there is data being corrupted in the double somehow?
Here's the function I'm playing with
I split it up to divide by 10 at a time when I found out it wasn't converting the number correctly.
Code:
double longDegreeToDouble(long degree) {
double divider = 10.00000000000000;
double degreeD = degree;
//if(D) { db << pstr("degreeD "); printFloat(degreeD,15); db << endl; }
if(D) db << pstr("degreeD ") << dec << setprecision(15) << degreeD << ' ' << dec << setprecision(15) << divider << endl;
for(int i=0;i<7;i++) {
degreeD /= divider;
//if(D) { db << pstr("degreeD "); printFloat(degreeD,15); db << endl; }
if(D) db << dec << i << pstr("degreeD ") << dec << setprecision(15) << degreeD << ' ' << dec << setprecision(15) << divider << endl;
}
return degreeD;
}
Here's an example of a latitude I'm putting into the function
-776591120
... and this is what it's printing
Code:
degreeD -776591120.000000000000000 10.000000000000000
0degreeD -77659112.000000000000000 10.000000000000000
1degreeD -7765911.200000000186264 10.000000000000000
2degreeD -776591.119999999995343 10.000000000000000
3degreeD -77659.111999999993713 10.000000000000000
4degreeD -7765.911199999999553 10.000000000000000
5degreeD -776.591119999999932 10.000000000000000
6degreeD -77.659111999999993 10.000000000000000
That third line is the problem. No idea where those numbers at the end are coming from and it throws everything else off. Is it possible there is data being corrupted in the double somehow?