How to merge two GPS coordinates without losing decimals

(deleted)

Serial.println(gps.location.lat(), 6);

The full number of decimal places is there whether or not they are printed. When printing a float the final parameter specifies how many decimal places are printed.

Here is some code for you to investigate

float a = 42.1234;
float b = 22.1234;

char aBuffer[10];
char bBuffer[20];
char outputBuffer[20];

void setup()
{
  Serial.begin(115200);
  dtostrf(a, 7, 4, aBuffer);
  dtostrf(b, 7, 4, bBuffer);
  sprintf(outputBuffer, "%s x %s", aBuffer, bBuffer);
  Serial.println(outputBuffer);
}

void loop()
{
}

(deleted)

(deleted)

I meant to ask.

Why do you want to do the conversion and concatenation in the first place ?

(deleted)

I asked because the sprintf() function causes quite a large increase in memory usage as do the buffers used and to compound things when using most Arduinos the formatting of floats using sprintf() is not supported hence the kludge of using dtostr() as an intermediary step.

Depending on the requirements it is often easier to send each element of the string as separate messages rather than trying to create a combined string which, whilst is sounds logical to do is often not necessary

(deleted)