MCPcopy Create free account
hub / github.com/RenderKit/embree / fpToString

Function fpToString

tutorials/external/catch.hpp:12419–12436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12417
12418template<typename T>
12419std::string fpToString( T value, int precision ) {
12420 if (Catch::isnan(value)) {
12421 return "nan";
12422 }
12423
12424 ReusableStringStream rss;
12425 rss << std::setprecision( precision )
12426 << std::fixed
12427 << value;
12428 std::string d = rss.str();
12429 std::size_t i = d.find_last_not_of( '0' );
12430 if( i != std::string::npos && i != d.size()-1 ) {
12431 if( d[i] == '.' )
12432 i++;
12433 d = d.substr( 0, i+1 );
12434 }
12435 return d;
12436}
12437
12438//// ======================================================= ////
12439//

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