Function dtos (o2scl)

O2scl : Function List

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 of std::numeric_limits::max_digits10 is used to determine the maximum precision. If prec is greater than this maximum value, then the maximum is used. If prec is 0, then std::numeric_limits::digits10 is used. The default value of prec is 6.

If auto_prec is false (the default), then the number is converted to a string in the ios::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.