MCPcopy Create free account
hub / github.com/FidoProject/Fido / fpToString

Function fpToString

tests/catch.h:8070–8083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8068
8069template<typename T>
8070std::string fpToString( T value, int precision ) {
8071 std::ostringstream oss;
8072 oss << std::setprecision( precision )
8073 << std::fixed
8074 << value;
8075 std::string d = oss.str();
8076 std::size_t i = d.find_last_not_of( '0' );
8077 if( i != std::string::npos && i != d.size()-1 ) {
8078 if( d[i] == '.' )
8079 i++;
8080 d = d.substr( 0, i+1 );
8081 }
8082 return d;
8083}
8084
8085std::string toString( const double value ) {
8086 return fpToString( value, 10 );

Callers 1

toStringFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected