MCPcopy Create free account
hub / github.com/apache/qpid-proton / fpToString

Function fpToString

tests/include/catch.hpp:15060–15077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15058
15059template<typename T>
15060std::string fpToString( T value, int precision ) {
15061 if (Catch::isnan(value)) {
15062 return "nan";
15063 }
15064
15065 ReusableStringStream rss;
15066 rss << std::setprecision( precision )
15067 << std::fixed
15068 << value;
15069 std::string d = rss.str();
15070 std::size_t i = d.find_last_not_of( '0' );
15071 if( i != std::string::npos && i != d.size()-1 ) {
15072 if( d[i] == '.' )
15073 i++;
15074 d = d.substr( 0, i+1 );
15075 }
15076 return d;
15077}
15078
15079//// ======================================================= ////
15080//

Callers 1

convertMethod · 0.85

Calls 4

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

Tested by

no test coverage detected