summaryrefslogtreecommitdiff
path: root/cesar/lib/fixed.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/lib/fixed.h')
-rw-r--r--cesar/lib/fixed.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/cesar/lib/fixed.h b/cesar/lib/fixed.h
index 6b9e598768..31e199ba2c 100644
--- a/cesar/lib/fixed.h
+++ b/cesar/lib/fixed.h
@@ -57,6 +57,20 @@ fixed_round (s32 x, uint shift)
}
/**
+ * Reduce fixed number precision, round to nearest, 64 bits version.
+ * \param x number to round
+ * \param shift precision reduction (1 to 63)
+ * \return number rounded
+ *
+ * Rounds to nearest, halfway up.
+ */
+extern inline s64
+fixed_round_64 (s64 x, uint shift)
+{
+ return (x + (1ll << (shift - 1))) >> shift;
+}
+
+/**
* Fixed point product.
* \param a first operand
* \param b second operand