Commit ca9c83f8 authored by gabime's avatar gabime

Minor improvment to number padding

parent fc900e24
...@@ -63,11 +63,9 @@ template<typename T> ...@@ -63,11 +63,9 @@ template<typename T>
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
{ {
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T"); static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
auto digits = count_digits(n); for(auto digits = count_digits(n); digits < width; digits++)
if (width > digits)
{ {
const char *zeroes = "0000000000000000000"; dest.push_back('0');
dest.append(zeroes, zeroes + width - digits);
} }
append_int(n, dest); append_int(n, dest);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment