mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-13 06:03:38 +00:00
Print leading zeroes after decimal point (#1265)
This commit is contained in:
parent
a44e8b9921
commit
fa4623db7c
@ -111,8 +111,8 @@ std::string to_string_dec_uint(
|
|||||||
auto term = p + sizeof(p) - 1;
|
auto term = p + sizeof(p) - 1;
|
||||||
auto q = to_string_dec_uint_pad_internal(term, n, l, fill);
|
auto q = to_string_dec_uint_pad_internal(term, n, l, fill);
|
||||||
|
|
||||||
// TODO: is this needed, seems like pad already does this.
|
|
||||||
// Right justify.
|
// Right justify.
|
||||||
|
// (This code is redundant and won't do anything if a fill character was specified)
|
||||||
while ((term - q) < l) {
|
while ((term - q) < l) {
|
||||||
*(--q) = ' ';
|
*(--q) = ' ';
|
||||||
}
|
}
|
||||||
@ -137,6 +137,7 @@ std::string to_string_dec_int(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Right justify.
|
// Right justify.
|
||||||
|
// (This code is redundant and won't do anything if a fill character was specified)
|
||||||
while ((term - q) < l) {
|
while ((term - q) < l) {
|
||||||
*(--q) = ' ';
|
*(--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);
|
string = to_string_dec_int(integer_part);
|
||||||
if (precision)
|
if (precision)
|
||||||
string += '.' + to_string_dec_uint(fractional_part, precision);
|
string += '.' + to_string_dec_uint(fractional_part, precision, '0');
|
||||||
|
|
||||||
if (prefix_index != 3)
|
if (prefix_index != 3)
|
||||||
string += unit_prefix[prefix_index];
|
string += unit_prefix[prefix_index];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user