in src/main/cpp/sdk/common/spdlog/fmt/bundled/format.h [2698:2756]
void basic_writer<Range>::write_double(T value, const format_specs &spec) {
// Check type.
float_spec_handler handler(static_cast<char>(spec.type));
internal::handle_float_type_spec(handler.type, handler);
char sign = 0;
// Use signbit instead of value < 0 because the latter is always
// false for NaN.
if (std::signbit(value)) {
sign = '-';
value = -value;
} else if (spec.has(SIGN_FLAG)) {
sign = spec.has(PLUS_FLAG) ? '+' : ' ';
}
struct write_inf_or_nan_t {
basic_writer &writer;
format_specs spec;
char sign;
void operator()(const char *str) const {
writer.write_padded(spec, inf_or_nan_writer{sign, str});
}
} write_inf_or_nan = {*this, spec, sign};
// Format NaN and ininity ourselves because sprintf's output is not consistent
// across platforms.
if (internal::fputil::isnotanumber(value))
return write_inf_or_nan(handler.upper ? "NAN" : "nan");
if (internal::fputil::isinfinity(value))
return write_inf_or_nan(handler.upper ? "INF" : "inf");
memory_buffer buffer;
bool use_grisu = FMT_USE_GRISU && sizeof(T) <= sizeof(double) &&
spec.type != 'a' && spec.type != 'A' &&
internal::grisu2_format(static_cast<double>(value), buffer, spec);
if (!use_grisu) {
format_specs normalized_spec(spec);
normalized_spec.type = handler.type;
internal::sprintf_format(value, buffer, normalized_spec);
}
size_t n = buffer.size();
align_spec as = spec;
if (spec.align() == ALIGN_NUMERIC) {
if (sign) {
auto &&it = reserve(1);
*it++ = static_cast<char_type>(sign);
sign = 0;
if (as.width_)
--as.width_;
}
as.align_ = ALIGN_RIGHT;
} else {
if (spec.align() == ALIGN_DEFAULT)
as.align_ = ALIGN_RIGHT;
if (sign)
++n;
}
write_padded(as, double_writer{n, sign, buffer});
}