Function dtos (o2scl)¶
-
template<class fp_t>
std::string o2scl::dtos(const fp_t &x, int prec = 6, bool auto_prec = false)¶ Convert a floating-point number to a string.
This uses a
ostringstream
object to convert the floating-point number to a string. The value ofstd::numeric_limits::max_digits10
is used to determine the maximum precision. Ifprec
is greater than this maximum value, then the maximum is used. Ifprec
is 0, thenstd::numeric_limits::digits10
is used. The default value ofprec
is 6.If
auto_prec
is false (the default), then the number is converted to a string in theios::scientific
mode, otherwise, neither the scientific or fixed mode flags are set and the number is converted to a string in “automatic” mode.
-
std::string o2scl::dtos(double x, std::ostream &format)¶
Convert a double to a string using a specified format.