MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / fpToString

Function fpToString

extlibs/catch/include/catch/catch.hpp:14326–14343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14324
14325template<typename T>
14326std::string fpToString( T value, int precision ) {
14327 if (Catch::isnan(value)) {
14328 return "nan";
14329 }
14330
14331 ReusableStringStream rss;
14332 rss << std::setprecision( precision )
14333 << std::fixed
14334 << value;
14335 std::string d = rss.str();
14336 std::size_t i = d.find_last_not_of( '0' );
14337 if( i != std::string::npos && i != d.size()-1 ) {
14338 if( d[i] == '.' )
14339 i++;
14340 d = d.substr( 0, i+1 );
14341 }
14342 return d;
14343}
14344
14345//// ======================================================= ////
14346//

Callers 1

convertMethod · 0.85

Calls 4

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

Tested by

no test coverage detected