From 6209251ca61b3b377981a511c1832d44f617d9c6 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 3 Aug 2022 12:53:28 +0200 Subject: [PATCH] Util: Pass floating-point precision to Format::Builder --- src/util/format/formatter.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util/format/formatter.cpp b/src/util/format/formatter.cpp index 6b8dd18..ecc7005 100644 --- a/src/util/format/formatter.cpp +++ b/src/util/format/formatter.cpp @@ -47,13 +47,23 @@ void Formatter::format(Builder& builder, size_t value) const template<> void Formatter::format(Builder& builder, float value) const { - builder.putF32(value); + if (specifier.precision < 0) { + builder.putF32(value); + } + else { + builder.putF32(value, specifier.precision); + } } template<> void Formatter::format(Builder& builder, double value) const { - builder.putF64(value); + if (specifier.precision < 0) { + builder.putF64(value); + } + else { + builder.putF64(value, specifier.precision); + } } // Char