boost format question

I need to format a string so that it is only a certain amount of characters long.

I have a function that returns an float which can be any number at all.
e.g.
1.123456
23.12345
0.123
123.123

I then have a function that uses boost and I am doing this:

1
2
3
4
void myFunction( float myFloat)
{
   std::string tmp = boost::str(boost::format("%1%")%myFloat);
}



The above will result in no formatting at all.
How do I format my number so that it is only ever 3 characters before the decimal point and 2 after the decimal point. i.e my string will only ever be 6 characters long (including the decimal point)

many thanks
Please don't make duplicate posts.
http://www.cplusplus.com/forum/general/30609/
ok sorry, I only saw this linux forum after I posted it in the general section.

Won't happen again..
From the example at: http://beta.boost.org/doc/libs/1_44_0/libs/format/doc/format.html it seems you should do something like:
1
2
3
4
5
6
void myFunction( float myFloat)
{
    format fmter("%1%");
    fmter % myFloat;
    string s  = fmter.str();
}


I've never used it, so I can't be sure.
Sorry, didn't see this thread. I answered here:

http://www.cplusplus.com/forum/general/30609/
Topic archived. No new replies allowed.