|
@@ -390,7 +390,11 @@ void FormatBuilder::put_f64(
|
|
|
StringBuilder string_builder;
|
|
|
FormatBuilder format_builder { string_builder };
|
|
|
|
|
|
- format_builder.put_i64(static_cast<i64>(value), base, false, upper_case, false, Align::Right, 0, ' ', sign_mode);
|
|
|
+ bool is_negative = value < 0.0;
|
|
|
+ if (is_negative)
|
|
|
+ value = -value;
|
|
|
+
|
|
|
+ format_builder.put_u64(static_cast<u64>(value), base, false, upper_case, false, Align::Right, 0, ' ', sign_mode, is_negative);
|
|
|
|
|
|
if (precision > 0) {
|
|
|
// FIXME: This is a terrible approximation but doing it properly would be a lot of work. If someone is up for that, a good
|
|
@@ -398,9 +402,6 @@ void FormatBuilder::put_f64(
|
|
|
// https://youtu.be/4P_kbF0EbZM (Stephan T. Lavavej “Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss”)
|
|
|
value -= static_cast<i64>(value);
|
|
|
|
|
|
- if (value < 0)
|
|
|
- value = -value;
|
|
|
-
|
|
|
double epsilon = 0.5;
|
|
|
for (size_t i = 0; i < precision; ++i)
|
|
|
epsilon /= 10.0;
|