MCPcopy Create free account
hub / github.com/apache/thrift / fpToString

Function fpToString

compiler/cpp/tests/catch/catch.hpp:8909–8922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8907
8908template<typename T>
8909std::string fpToString( T value, int precision ) {
8910 std::ostringstream oss;
8911 oss << std::setprecision( precision )
8912 << std::fixed
8913 << value;
8914 std::string d = oss.str();
8915 std::size_t i = d.find_last_not_of( '0' );
8916 if( i != std::string::npos && i != d.size()-1 ) {
8917 if( d[i] == '.' )
8918 i++;
8919 d = d.substr( 0, i+1 );
8920 }
8921 return d;
8922}
8923
8924std::string toString( const double value ) {
8925 return fpToString( value, 10 );

Callers 1

toStringFunction · 0.85

Calls 3

strMethod · 0.80
sizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected