T
tarmat
I'm trying to create a function that will turn a float into a
std::string that always shows the number to two decimal places. I have
the following but it doesn't give the desired output:
inline std::string ftos(float f)
{
std:stringstream buffer;
buffer << std::setprecision(2) << f;
return buffer.str();
}
for example
ftos (34.22) gives "34"
ftos(3.123) gives "3.1"
how do I create a function that will simply chop of all the digits
after the second digit from the decimal point?
thanks
std::string that always shows the number to two decimal places. I have
the following but it doesn't give the desired output:
inline std::string ftos(float f)
{
std:stringstream buffer;
buffer << std::setprecision(2) << f;
return buffer.str();
}
for example
ftos (34.22) gives "34"
ftos(3.123) gives "3.1"
how do I create a function that will simply chop of all the digits
after the second digit from the decimal point?
thanks