Juergen Spitzmueller wrote: > Angus Leeming wrote: >> QString float2qstr(float value, size_t precision) >> { >> std::ostringstream ss; >> ss << setprecision(precision) << value; >> return toqstr(ss.str()); >> } > > Since this problem is frontend-independent, I will add an > appropriate function to lstrings (correct place, or rather tostr?).
Why not float tostr(float value, int precision = -1) { std::ostringstream ss; if (precision < 0) ss << value; else ss << setprecision(precision) << value; return ss.str(); } // Ditto for 'double'. double tostr(double value, int precision = -1); > (BTW this seems to be a restriction of boost::lexical_cast, which is > used in tostr. Search the web for "lexical_cast precision". Maybe > there's also a method for lexical_cast; I have to investigate this > further) > > I will come back to it after my return in a few days. Have a good trip. -- Angus