Concate the int number

i have m1=12345 and m2=23456, i want m3=1234523456 and send to another arduino with nrf24L01. In the other arduino i want separate m3 become m1 and m2 automatically. How can I do it?

m3=m1*100000+m2

50 cents please

I would use:

long concatenator(int m1, int m2) {
  long multiplier = 1;
  while(m2>=multiplier) {
    multiplier*=10;
  }
  return m1*multiplier + m2;
}

But the example is perilously close to the largest long integer and if the numbers might get bigger than this in actual use, I would consider a long long or change the representation entirely.

The single example is also missing any detail on the edge cases. What if m2 is zero? If m1=12 and m2=0 then my code above will return 12. What if one or both are negative?

Couldn't this be done easily with itoa() and strcat()?

Why even store the result in an intermediate variable. If it's for sending out, then just send both numbers:

 RadioModem.print(m1);
  RadioModem.print(m2);

Of course the other end has no information to split the numbers back into the original components so this seems a stupid thing to do.

MorganS: Why even store the result in an intermediate variable. If it's for sending out, then just send both numbers: ... Of course the other end has no information to split the numbers back into the original components so this seems a stupid thing to do.

If the numbers have a fix length and the receiver knows how long, it can still work...