Template Function to_string_prec

Function Documentation

template<typename T>
std::string to_string_prec(const T value_in, const int prec = 6)

convert a numeric value to a string with specified precision

Since std::to_string doesn’t allow changing the precision, I wrote my own equivalent. Probably don’t want to use this in a tight loop.

Parameters:
  • value_in[in] numeric value in of type <T>

  • prec[in] desired precision, default=6

Returns:

string