I have this:
#include <iostream>
#include <iomanip>
std::string ExampleInstance::RoundNumber(float result) {
std::string RoundResult;
std::cout << std::fixed << std::showpoint;
std::cout << std::setprecision(1);
std::cout << result << std::endl;
RoundResult = std::to_string(result);
return RoundResult;
}
I want to pass this method a float, round it to one decimal place, convert it to a string and then return it. Currently this doesn't do anything to the number.
Would setPrecision
be more effective? I'm new to C++.