From fa4623db7c957f4b4b40525161c2aedf9ead3229 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Wed, 12 Jul 2023 13:00:45 -0500 Subject: [PATCH] Print leading zeroes after decimal point (#1265) --- firmware/application/string_format.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 9d267e8e1..a2fdb56ed 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -111,8 +111,8 @@ std::string to_string_dec_uint( auto term = p + sizeof(p) - 1; auto q = to_string_dec_uint_pad_internal(term, n, l, fill); - // TODO: is this needed, seems like pad already does this. // Right justify. + // (This code is redundant and won't do anything if a fill character was specified) while ((term - q) < l) { *(--q) = ' '; } @@ -137,6 +137,7 @@ std::string to_string_dec_int( } // Right justify. + // (This code is redundant and won't do anything if a fill character was specified) while ((term - q) < l) { *(--q) = ' '; } @@ -285,7 +286,7 @@ std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precisi string = to_string_dec_int(integer_part); if (precision) - string += '.' + to_string_dec_uint(fractional_part, precision); + string += '.' + to_string_dec_uint(fractional_part, precision, '0'); if (prefix_index != 3) string += unit_prefix[prefix_index];