Functions dtos¶
-
template<class
fp_t
>
std::stringo2scl
::
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. It usesstd::numeric_limits::max_digits10
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.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.