summaryrefslogtreecommitdiff
path: root/src/fixed_point.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fixed_point.cpp')
-rw-r--r--src/fixed_point.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fixed_point.cpp b/src/fixed_point.cpp
index 9b2d8e2..847a5f7 100644
--- a/src/fixed_point.cpp
+++ b/src/fixed_point.cpp
@@ -8,6 +8,15 @@ fp_t fp_t::operator-(const fp_t& other) const {
return {(int32_t)((uint32_t)raw - (uint32_t)other.raw)};
}
+fp_t fp_t::operator*(const fp_t& other) const {
+ int32_t result;
+ int64_t temp;
+ temp = (int64_t)raw * (int64_t)other.raw;
+ temp += fp_t::K;
+ result = (int32_t)(temp >> fp_t::Q);
+ return {result};
+}
+
bool fp_t::operator==(const fp_t& other) const {
return raw == other.raw;
}