diff options
| author | batsumaru <> | 2026-08-09 12:39:50 +0900 |
|---|---|---|
| committer | batsumaru <> | 2026-08-09 12:39:50 +0900 |
| commit | 7bb49794297b46aa1c577e89da24d39b4348c6d4 (patch) | |
| tree | 89b1d4a1f044546e15fbbd0dde370eddc6e7b4b9 /src/fixed_point.cpp | |
| parent | 9d4f68606c919791d44e86e7a50812c29be32fa3 (diff) | |
Added fp_t multiplication
Diffstat (limited to 'src/fixed_point.cpp')
| -rw-r--r-- | src/fixed_point.cpp | 9 |
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; } |
