| 8068 | |
| 8069 | template<typename T> |
| 8070 | std::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 | |
| 8085 | std::string toString( const double value ) { |
| 8086 | return fpToString( value, 10 ); |