MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / fpToString

Function fpToString

Bcore/src/main/cpp/Dobby/tests/catch.hpp:10563–10578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10561} // namespace Detail
10562
10563template <typename T> std::string fpToString(T value, int precision) {
10564 if (std::isnan(value)) {
10565 return "nan";
10566 }
10567
10568 ReusableStringStream rss;
10569 rss << std::setprecision(precision) << std::fixed << value;
10570 std::string d = rss.str();
10571 std::size_t i = d.find_last_not_of('0');
10572 if (i != std::string::npos && i != d.size() - 1) {
10573 if (d[i] == '.')
10574 i++;
10575 d = d.substr(0, i + 1);
10576 }
10577 return d;
10578}
10579
10580//// ======================================================= ////
10581//

Callers 1

convertMethod · 0.85

Calls 3

strMethod · 0.45
sizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected