| 32 | namespace utils { |
| 33 | |
| 34 | std::string commify(size_t n) |
| 35 | { |
| 36 | std::string s = std::to_string(n); |
| 37 | std::stringstream s2; |
| 38 | int c = 0; |
| 39 | for (int j = (int)s.size() - 1; j >= 0; j--) { |
| 40 | s2 << s[j]; |
| 41 | ++c; |
| 42 | if (c == 3) { |
| 43 | if (j > 0) { |
| 44 | s2 << ","; |
| 45 | c = 0; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | std::string r = s2.str(); |
| 50 | std::reverse(r.begin(), r.end()); |
| 51 | return r; |
| 52 | } |
| 53 | |
| 54 | } // namespace utils |
| 55 | } // namespace lbann |