Formatted write
ATmega328P.pdf ( Register summary on p 428 )The C language has the versatile function printf() for formatted output of variables together along with prompts. This function has everything you could wish for, and more. The risk is that it takes far too much space in a small low-cost processor.
You might as well program only the formatting options that you really need.

The function void decimal_out_uart( signed int number, unsigned char fixed_decimals, char format ) prints an int (16 bit) as five decimal digits with or without sign. A decimal comma/decimal point can if necessary be inserted between the digits at any numeric position.
The full program is available here:
print.txt
(for Arduino use code stored as: print\print.ino)
William Sandqvist william@kth.se