| 8907 | |
| 8908 | template<typename T> |
| 8909 | std::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 | |
| 8924 | std::string toString( const double value ) { |
| 8925 | return fpToString( value, 10 ); |