I have tweaked the dec2str() function and renamed dec2strf(), available here in an example sketch.
dec2strf(floatValue, precision);
returns a pointer to a string with "precision" digits after the decimal point. precision is deliberately limited to 7 maximum.
ILI9341 TFT users may be interested to know that the function has been built into the TFT_ILI9341 graphics library as drawFloat(value, precision, x, y , font). A typical use is to display parameters (temperature voltage etc) on the TFT.
I decided to poke around in the Arduino IDE directory to see if I could find the function that print uses, it was easy to find at the very end of the Print.cpp file buried here:
a few extra checks are included like "not a number" and divide by zero (viz. infinity) but the function otherwise uses the same approach as I ended up using in the dec2strf function.