MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / fpToString

Function fpToString

tests/catch.hpp:17476–17492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17474}
17475
17476template<typename T> std::string fpToString(T value, int precision)
17477{
17478 if (Catch::isnan(value)) {
17479 return "nan";
17480 }
17481
17482 ReusableStringStream rss;
17483 rss << std::setprecision(precision) << std::fixed << value;
17484 std::string d = rss.str();
17485 std::size_t i = d.find_last_not_of('0');
17486 if (i != std::string::npos && i != d.size() - 1) {
17487 if (d[i] == '.')
17488 i++;
17489 d = d.substr(0, i + 1);
17490 }
17491 return d;
17492}
17493
17494//// ======================================================= ////
17495//

Callers 1

convertMethod · 0.85

Calls 4

isnanFunction · 0.85
strMethod · 0.80
sizeMethod · 0.80
substrMethod · 0.80

Tested by

no test coverage detected