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
ostringstreamobject to convert the floating-point number to a string. The value ofstd::numeric_limits::max_digits10is used to determine the maximum precision. Ifprecis greater than this maximum value, then the maximum is used. Ifprecis 0, thenstd::numeric_limits::digits10is used. The default value ofprecis 6.If
auto_precis false (the default), then the number is converted to a string in theios::scientificmode, 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.