It depends on what format you want. For a fixed decimal place,
something like:
class FFmt
{
int myWidth;
int myPrecision;
public:
FFmt( int width, int precision )
: myWidth( width )
, myPrecision( precision )
{
}
friend std::ostream& operator<<(
std::ostream& dest,
FFmt const& fmt )
{
dest.setf( std::ios::fixed, std::ios::floatfield );
dest.precision( myPrecision );
dest.width( myWidth );
}
};
should do the trick, so you can write:
file << nume << '\t' << FFmt( 8, 2 ) << max ...
(or whatever width and precision you want).
If you're doing any floating point work at all, you should probably have
such a manipulator in your took kit (although in many cases, it will be
more appropriate to use a logical manipulator, named after the logical
meaning of the data it formats, e.g. degree, distances, etc.).
IMHO, it's also worth extending the manipulators so that they save the
formatting state, and restore it at the end of the full expression.
(All of my manipulators derive from a base class which handles this.)