rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
dtoa: float64 to chars

Functions

size_t c4::dtoa (substr str, double v, int precision=-1, RealFormat_e formatting=FTOA_FLEX) noexcept
 Convert a double-precision real number to string.

Detailed Description

Function Documentation

◆ dtoa()

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

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. It is safe to call this function with an empty or too-small buffer.

Returns
the size of the buffer needed to write the number

Definition at line 2097 of file charconv.hpp.

2098{
2099#if C4CORE_HAVE_STD_TOCHARS
2100 return detail::rtoa(str, v, precision, formatting);
2101#else
2102 char fmt[16];
2103 detail::get_real_format_str(fmt, precision, formatting, /*length_modifier*/"l");
2104 return detail::print_one(str, fmt, v);
2105#endif
2106}

Referenced by to_chars(), to_chars(), xtoa(), and xtoa().