B
Brandon
In a program, I'm using an ostringstream to convert a floating point
value to a string. When the numbers are big enough, they are
converted using scientific notation. To fix this, I changed the code
to
oStream << fixed << myFloat;
but now there are an unnecessary amount of trailing zeros that I don't
want. I seem to recall something in C, using printf(), where you
could specify how many places you wanted. For examples, using
something like printf("%1.2", 0.45678) would print the text "0.45".
Is there any way to force a certain number of decimal places in C++
using ios streams (ostringstreams in particular)?
-Brandon
value to a string. When the numbers are big enough, they are
converted using scientific notation. To fix this, I changed the code
to
oStream << fixed << myFloat;
but now there are an unnecessary amount of trailing zeros that I don't
want. I seem to recall something in C, using printf(), where you
could specify how many places you wanted. For examples, using
something like printf("%1.2", 0.45678) would print the text "0.45".
Is there any way to force a certain number of decimal places in C++
using ios streams (ostringstreams in particular)?
-Brandon