summaryrefslogtreecommitdiff
path: root/src/Util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Util.cc')
-rw-r--r--src/Util.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Util.cc b/src/Util.cc
index 0300e52b..a97ffe50 100644
--- a/src/Util.cc
+++ b/src/Util.cc
@@ -220,3 +220,24 @@ timeval normalizeTimeval(const timeval &tm) {
return ret;
}
+
+
+string itostring(unsigned long i) {
+ if (i == 0)
+ return string("0");
+
+ string tmp;
+ for (; i > 0; i /= 10)
+ tmp.insert(tmp.begin(), "0123456789"[i%10]);
+ return tmp;
+}
+
+
+string itostring(long i) {
+ if (i < 0) {
+ std::string tmp = itostring( (unsigned long) -i);
+ tmp.insert(tmp.begin(), '-');
+ return tmp;
+ } else
+ return itostring( (unsigned long) i);
+}