summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 25fbc130b..f604cd10a 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -1016,3 +1016,13 @@ entities_to_text (string e)
boost::algorithm::replace_all (e, "%2F", "/");
return e;
}
+
+int64_t
+divide_with_round (int64_t a, int64_t b)
+{
+ if (a % b >= (b / 2)) {
+ return (a + b - 1) / b;
+ } else {
+ return a / b;
+ }
+}