Commit 18797367 authored by Mathieu Giraud's avatar Mathieu Giraud

core/tools.{h,cpp}: string_of_int(..., pad_to_width)

parent 2ce9d1d7
...@@ -71,10 +71,10 @@ string spaced(const string &input, const string &seed) { ...@@ -71,10 +71,10 @@ string spaced(const string &input, const string &seed) {
} }
string string_of_int(int number) string string_of_int(int number, int w)
{ {
stringstream ss; stringstream ss;
ss << number ; ss << setfill('0') << setw(w) << number ;
return ss.str(); return ss.str();
} }
......
...@@ -109,7 +109,7 @@ template <class T> ...@@ -109,7 +109,7 @@ template <class T>
bool pair_occurrence_sort(pair<T, int> a, pair<T, int> b); bool pair_occurrence_sort(pair<T, int> a, pair<T, int> b);
string string_of_int(int number); string string_of_int(int number, int pad_to_width=0);
string fixed_string_of_float(float number, int precision); string fixed_string_of_float(float number, int precision);
string scientific_string_of_double(double number); string scientific_string_of_double(double number);
string string_of_map(map <string, string> m, const string &before); string string_of_map(map <string, string> m, const string &before);
......
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