converting GPS coordinates

hello
i have the problem i do not know where to store a variable like 5437,374849 in since my double only puts out 2 decimals :S

my code is just getting the degrees out and the decimal seconds
then dividing the decimal seconds by 60 and adding them to the degrees again
but then it puts out 4 digits ..(2 decimals) :frowning: i need more than 4
i commented extra well hope you understand :slight_smile:

the arguments array contains:
5317.7621 on [2]
00635.9706 on [4]

double latD = 0;
double lonD = 0;
double latX = 0;
double lonX = 0;
double latXX = 0;
double lonXX = 0;
double latXXX = 0;
double lonXXX = 0;
double lat = NULL;
double lon = NULL;
// first get the numbers from the array and store them in my own array ( yes it is kind of a detour 
// but still it is easyer this way i think since i was getting errors i could not transform
// the variables and stuff..

// lat deg
tijdelijk[0][0] = GPS.arguments[2][0];
tijdelijk[0][1] = GPS.arguments[2][1];

//lon deg
tijdelijk[1][0] = GPS.arguments[4][0];
tijdelijk[1][1] = GPS.arguments[4][1];
tijdelijk[1][2] = GPS.arguments[4][2];

// decimal minutes of lat
tijdelijk[2][0] = GPS.arguments[2][2];
tijdelijk[2][1] = GPS.arguments[2][3];

// the rest of the decimal lat minutes (the precise kind:P)
tijdelijk[3][0] = GPS.arguments[2][5];
tijdelijk[3][1] = GPS.arguments[2][6];
tijdelijk[3][2] = GPS.arguments[2][7];
tijdelijk[3][3] = GPS.arguments[2][8];

// decimal minutes of lon
tijdelijk[4][0] = GPS.arguments[4][3];
tijdelijk[4][1] = GPS.arguments[4][4];

// the rest of the decimal lon minutes
tijdelijk[5][0] = GPS.arguments[4][6];
tijdelijk[5][1] = GPS.arguments[4][7];
tijdelijk[5][2] = GPS.arguments[4][8];
tijdelijk[5][3] = GPS.arguments[4][9];

// then store the array in separate variables X is decimal and XX is decimal after the , the XXX part was temporary 
// i don't understand the (char*) bit but it worked this way :P
 latD = atol((char*)tijdelijk[0]);
 lonD = atol((char*)tijdelijk[1]);
 latX = atoi((char*)tijdelijk[2]);
 latXX =atoi((char*)tijdelijk[3]);
 lonX = atoi((char*)tijdelijk[4]);
 lonXX =atoi((char*)tijdelijk[5]);
 lat =  (latD + (latX / 60)); // the first part. the lon still to follow once lat works
 
 Serial.println("from here:");
 Serial.print("%0.4f /n", lat); // i was a bit experimenting with the "%0.4f /n",  but i get the ambiguous over and over
 Serial.println(lon);
 Serial.println(latD);
 Serial.println(lonD); 
 Serial.println(latX);
 Serial.println(lonX); 
 Serial.println(latXX);
 Serial.println(lonXX);
 Serial.println(latXXX);

thank you
diamantmatch

If you use 0018, you can print as many decimal places as you like.

"e.g. Serial.print (floatVal, 4);" will print four places after the decimal point.

BTW, on the Arduino, "double" == "float".