12 return value >= -3.40282347e38f &&
value <= 3.40282347e38f;
16 const bool negative =
value < 0.0f;
19 while (magnitude >= 10.0f) {
23 while (magnitude > 0.0f && magnitude < 1.0f) {
33 float half_step = 0.5f;
34 for (
int digit = 0; digit < precision; ++digit) {
37 if (magnitude >= 10.0f - half_step) {
71 default: temp << a.s;
break;
95 bool is_numeric =
false;
102 stream_integral(temp, a);
108 if (spec.show_sign) {
110 }
else if (spec.space_sign) {
120 stream_integral(temp, a);
129 if (spec.alt_form && a.u != 0) {
138 const bool negative = a.s < 0;
139 const fl::u64 magnitude =
140 negative ?
static_cast<fl::u64
>(0) - a.u : a.u;
144 negative, spec.uppercase,
false);
145 if (spec.alt_form && a.u != 0) {
156 char temp_str[2] = {
static_cast<char>(a.u),
'\0'};
163 stream_integral(temp, a);
169 result =
"<unknown_format>";
172 emit_padded(stream, spec,
result, is_numeric);
178 bool is_numeric =
false;
194 const bool nonzero = is_float ? a.f != 0.0f : a.d != 0.0;
195 if (spec.alt_form && nonzero) {
205 if (spec.precision >= 0) {
217 stream_floating(temp, a);
223 result =
"<unknown_format>";
226 emit_padded(stream, spec,
result, is_numeric);
244 const auto flush_buffer = [&]() {
253 const auto append = [&](
const char* text) {
255 if (used ==
sizeof(output) - 1) {
258 output[used++] = *text++;
266 append(spec.
type ==
'%' ?
"%" :
"<missing_arg>");
280 append(
"<missing_arg>");
284 if (used ==
sizeof(output) - 1) {
287 output[used++] = *
format++;
293 if (!buffer || size == 0) {
297 fl::size written = 0;
298 const auto append_char = [&](
char value) {
299 if (written < size - 1) {
300 buffer[written++] =
value;
303 const auto append_text = [&](
const char* text) {
304 while (*text && written < size - 1) {
305 buffer[written++] = *text++;
309 while (*
format && written < size - 1) {
313 append_text(spec.
type ==
'%' ?
"%" :
"<missing_arg>");
327 append_text(
"<missing_arg>");
333 buffer[written] =
'\0';
334 return static_cast<int>(written);
string str() const FL_NO_EXCEPT
fl::string hex(u64 value, HexIntWidth width, bool is_negative, bool uppercase, bool pad_to_width)
Internal hex conversion function (implementation in charconv.cpp)
HexIntWidth
Integer width classification for hex conversion.
void stream_integral(sstream &temp, const ScalarArg &a) FL_NO_EXCEPT
void stream_floating(sstream &temp, const ScalarArg &a) FL_NO_EXCEPT
void emit_padded(sstream &stream, const FormatSpec &spec, const fl::string &result, bool is_numeric) FL_NO_EXCEPT
void format_arg(sstream &stream, const FormatSpec &spec, const fl::string &arg) FL_NO_EXCEPT
fl::string apply_width(const fl::string &str, const FormatSpec &spec, bool is_numeric=false) FL_NO_EXCEPT
fl::string to_octal(T value) FL_NO_EXCEPT
fl::string format_float(float value, int precision) FL_NO_EXCEPT
bool float_is_finite(float value) FL_NO_EXCEPT
FormatSpec parse_format_spec(const char *&format) FL_NO_EXCEPT
void format_floating(sstream &stream, const FormatSpec &spec, const ScalarArg &a) FL_NO_EXCEPT
fl::string format_float_scientific(float value, int precision) FL_NO_EXCEPT
void format_integral(sstream &stream, const FormatSpec &spec, const ScalarArg &a) FL_NO_EXCEPT
constexpr int type_rank< T >::value
int snprintf(char *buffer, fl::size size, const char *format) FL_NO_EXCEPT
void print(const char *str)
void printf(const char *format) FL_NO_EXCEPT
fl::string to_hex(T value, bool uppercase=false, bool pad_to_width=false) FL_NO_EXCEPT
Convert an integer value to hexadecimal string representation.
expected< T, E > result
Alias for expected (Rust-style naming)
InputGamut g FL_NO_EXCEPT
fl::string format(const char *fmt)
Format with no arguments.
Base definition for an LED controller.