Function dtoa

Synopsis

#include <src/c4/charconv.hpp>

size_t dtoa(substr str, double v, int precision=-1, RealFormat_e formatting=FTOA_FLEX)

Description

Convert a double-precision real number to string. The string will in general be NOT null-terminated. For FTOA_FLEX, precision is the number of significand digits. Otherwise precision is the number of decimals.

Returns
the number of characters written.

Mentioned in

Source

Lines 1166-1175 in src/c4/charconv.hpp.

inline size_t dtoa(substr str, double v, int precision=-1, RealFormat_e formatting=FTOA_FLEX)
{
#if C4CORE_HAVE_STD_TOCHARS
    return detail::rtoa(str, v, precision, formatting);
#else
    char fmt[16];
    detail::get_real_format_str(fmt, precision, formatting, /*length_modifier*/"l");
    return detail::print_one(str, fmt, v);
#endif
}





Add Discussion as Guest

Log in