15constexpr bool Writer::UsesFloatTextBackend(FormatType type)
19 case FormatType::FloatScientific:
20 case FormatType::DoubleScientific:
21 case FormatType::LongDoubleScientific:
22 case FormatType::FloatGeneral:
23 case FormatType::DoubleGeneral:
24 case FormatType::LongDoubleGeneral:
25 case FormatType::FloatFixed:
26 case FormatType::DoubleFixed:
27 case FormatType::LongDoubleFixed:
41constexpr bool Writer::FloatEnabled(FormatType type)
45 case FormatType::FloatFixed:
46 return Config::enable_float_fixed;
47 case FormatType::FloatScientific:
48 return Config::enable_float_scientific;
49 case FormatType::FloatGeneral:
50 return Config::enable_float_general;
51 case FormatType::DoubleFixed:
52 return Config::enable_float_double && Config::enable_float_fixed;
53 case FormatType::DoubleScientific:
54 return Config::enable_float_double && Config::enable_float_scientific;
55 case FormatType::DoubleGeneral:
56 return Config::enable_float_double && Config::enable_float_general;
57 case FormatType::LongDoubleFixed:
58 return Config::enable_float_long_double && Config::enable_float_fixed;
59 case FormatType::LongDoubleScientific:
60 return Config::enable_float_long_double && Config::enable_float_scientific;
61 case FormatType::LongDoubleGeneral:
62 return Config::enable_float_long_double && Config::enable_float_general;
73constexpr uint8_t Writer::DefaultFloatPrecision()
75 return Config::max_float_precision < 6 ? Config::max_float_precision : 6;
88template <
typename Float>
89bool Writer::ExceedsFixedIntegerDigits(Float value, uint8_t precision)
91 if (!std::isfinite(value))
96 Float rounded = RoundDecimal(value, precision);
97 if (!std::isfinite(rounded))
105 return 1 > Config::max_float_integer_digits;
108 auto normalized = NormalizeDecimal(rounded);
109 size_t integer_digits =
110 (normalized.exponent >= 0) ?
static_cast<size_t>(normalized.exponent) + 1U : 1U;
111 return integer_digits > Config::max_float_integer_digits;