MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / fpToString

Function fpToString

deps/Catch/catch.hpp:14945–14962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14943
14944template<typename T>
14945std::string fpToString( T value, int precision ) {
14946 if (Catch::isnan(value)) {
14947 return "nan";
14948 }
14949
14950 ReusableStringStream rss;
14951 rss << std::setprecision( precision )
14952 << std::fixed
14953 << value;
14954 std::string d = rss.str();
14955 std::size_t i = d.find_last_not_of( '0' );
14956 if( i != std::string::npos && i != d.size()-1 ) {
14957 if( d[i] == '.' )
14958 i++;
14959 d = d.substr( 0, i+1 );
14960 }
14961 return d;
14962}
14963
14964//// ======================================================= ////
14965//

Callers 1

convertMethod · 0.85

Calls 4

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

Tested by

no test coverage detected