MCPcopy Create free account
hub / github.com/catchorg/Catch2 / fpToString

Function fpToString

extras/catch_amalgamated.cpp:2038–2055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2036
2037 template<typename T>
2038 std::string fpToString(T value, int precision) {
2039 if (Catch::isnan(value)) {
2040 return "nan";
2041 }
2042
2043 ReusableStringStream rss;
2044 rss << std::setprecision(precision)
2045 << std::fixed
2046 << value;
2047 std::string d = rss.str();
2048 std::size_t i = d.find_last_not_of('0');
2049 if (i != std::string::npos && i != d.size() - 1) {
2050 if (d[i] == '.')
2051 i++;
2052 d = d.substr(0, i + 1);
2053 }
2054 return d;
2055 }
2056 } // end unnamed namespace
2057
2058 std::size_t catch_strnlen( const char* str, std::size_t n ) {

Callers 1

convertMethod · 0.70

Calls 4

isnanFunction · 0.70
strMethod · 0.45
sizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected