From db3729992ef76f5d708a8618aa24dfe91daa9bb8 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 22 Jul 2023 23:10:50 -0700 Subject: [PATCH] math/fp: add shift operators --- math/fp.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/math/fp.hpp b/math/fp.hpp index 8f9c9ab..7b5b6eb 100644 --- a/math/fp.hpp +++ b/math/fp.hpp @@ -89,6 +89,18 @@ constexpr inline fp operator+(const fp& a, const fp& return fp(a.value + b.value, fp_raw_tag{}); } +template +constexpr inline fp operator>>(const fp& a, int s) +{ + return fp(a.value >> s, fp_raw_tag{}); +} + +template +constexpr inline fp operator<<(const fp& a, int s) +{ + return fp(a.value << s, fp_raw_tag{}); +} + template constexpr inline fp operator-(const fp& a, const fp& b) {