summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/math_util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h
index 98dfdbec84..124801ff5d 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -114,6 +114,17 @@ static inline fp_t fp_abs(fp_t a)
return (a >= INT_TO_FP(0) ? a : -a);
}
+/*
+ * Return the smallest positive X where M * X >= N.
+ *
+ * For example, if n = 88 and m = 9, then it returns 10
+ * (i.e. 9 * 10 >= 88).
+ */
+static inline int ceil_for(int n, int m)
+{
+ return (((n - 1) / m) + 1);
+}
+
/**
* Square root
*/