rapidyaml  0.16.0
parseandemitYAML,anddoitfast
ftoa: float32 to chars

Functions

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

Detailed Description

Function Documentation

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

Convert a single-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 2071 of file charconv.hpp.

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

2072 {
2073 #if C4CORE_HAVE_STD_TOCHARS
2074  return detail::rtoa(str, v, precision, formatting);
2075 #else
2076  char fmt[16];
2077  detail::get_real_format_str(fmt, precision, formatting, /*length_modifier*/"");
2078  return detail::print_one(str, fmt, v);
2079 #endif
2080 }
const char * str
Definition: node_type.cpp:70