I do not have too much experience with AVR assembly and considering the IDE support for assembly I gave up on that immediately.
"I don't understand" is a poor excuse for giving up.
"__ftoa_engine" does most of the hard work and probably more efficient then what I could write. However I do not know how to include it or use it. If I learn to do that, the rest is done in few minutes. But I do not know how to include this file.
Figuring it out would be a better use of time than re-writing it. As you say, adding a "max field width" to the ftoa_engine should be relatively trivial.
#include <avr/io.h>
I could not find this one though. I thought this is supposed to be the easiest one.
That's because this is Atmel-provided code rather than avr-libc, or something like that.
it shows up in the installed toolchain in .../avr/include/avr/io.h
Also, __ftoa_engine should certainly be in libc. Make sure to declare it as a C function, in c++ or ino files:
extern "C" int __ftoa_engine (double val, char *buf, unsigned char prec, unsigned char maxdgs);