MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/TriangleMeshDistance / fpToString

Function fpToString

tests/catch.hpp:12147–12164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12145
12146template<typename T>
12147std::string fpToString( T value, int precision ) {
12148 if (Catch::isnan(value)) {
12149 return "nan";
12150 }
12151
12152 ReusableStringStream rss;
12153 rss << std::setprecision( precision )
12154 << std::fixed
12155 << value;
12156 std::string d = rss.str();
12157 std::size_t i = d.find_last_not_of( '0' );
12158 if( i != std::string::npos && i != d.size()-1 ) {
12159 if( d[i] == '.' )
12160 i++;
12161 d = d.substr( 0, i+1 );
12162 }
12163 return d;
12164}
12165
12166//// ======================================================= ////
12167//

Callers 1

convertMethod · 0.85

Calls 4

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

Tested by

no test coverage detected