99 using ::double_conversion::DoubleToStringConverter;
100 using ::double_conversion::StringBuilder;
105 arg.presentation =
'g';
108 const char* infinitySymbol = isupper(arg.presentation) ?
"INF" :
"inf";
109 const char* nanSymbol = isupper(arg.presentation) ?
"NAN" :
"nan";
110 char exponentSymbol = isupper(arg.presentation) ?
'E' :
'e';
117 constexpr
int bufLen = 2 +
118 constexpr_max(2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
119 DoubleToStringConverter::kMaxFixedDigitsAfterPoint,
121 8 + DoubleToStringConverter::kMaxExponentialDigits,
122 7 + DoubleToStringConverter::kMaxPrecisionDigits));
124 StringBuilder
builder(buf + 1, bufLen - 1);
139 auto flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
140 (arg.trailingDot ? DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT
144 switch (arg.presentation) {
150 if (arg.precision > DoubleToStringConverter::kMaxFixedDigitsAfterPoint) {
151 arg.precision = DoubleToStringConverter::kMaxFixedDigitsAfterPoint;
153 DoubleToStringConverter conv(
163 conv.ToFixed(val, arg.precision, &
builder),
164 "fixed double conversion failed");
169 if (arg.precision > DoubleToStringConverter::kMaxExponentialDigits) {
170 arg.precision = DoubleToStringConverter::kMaxExponentialDigits;
173 DoubleToStringConverter conv(
182 arg.enforce(conv.ToExponential(val, arg.precision, &
builder));
188 if (arg.precision < DoubleToStringConverter::kMinPrecisionDigits) {
189 arg.precision = DoubleToStringConverter::kMinPrecisionDigits;
190 }
else if (arg.precision > DoubleToStringConverter::kMaxPrecisionDigits) {
191 arg.precision = DoubleToStringConverter::kMaxPrecisionDigits;
193 DoubleToStringConverter conv(
202 arg.enforce(conv.ToShortest(val, &
builder));
206 arg.error(
"invalid specifier '", arg.presentation,
"'");
217 if (plusSign && (*p !=
'-' && *p !=
'n' && *p !=
'N')) {
221 }
else if (*p ==
'-') {
constexpr T constexpr_max(T a)
basic_fbstring< char > fbstring
#define FOLLY_FALLTHROUGH