From 543218e48946bb370c9713a22e3e92143b89db58 Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Sun, 18 Aug 2024 14:10:44 -0700 Subject: [PATCH] Add fixed point comparison operators --- include/mtl/fixed.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/mtl/fixed.hpp b/include/mtl/fixed.hpp index 432995c..96d7d83 100644 --- a/include/mtl/fixed.hpp +++ b/include/mtl/fixed.hpp @@ -167,6 +167,28 @@ public: *this = *this / rhs; return *this; } + + /** + * \brief Comparison operators + */ + constexpr fixed operator==(fixed rhs) const noexcept { + return x == rhs.x; + } + constexpr fixed operator!=(fixed rhs) const noexcept { + return x != rhs.x; + } + constexpr fixed operator>(fixed rhs) const noexcept { + return x > rhs.x; + } + constexpr fixed operator>=(fixed rhs) const noexcept { + return x >= rhs.x; + } + constexpr fixed operator<(fixed rhs) const noexcept { + return x < rhs.x; + } + constexpr fixed operator<=(fixed rhs) const noexcept { + return x <= rhs.x; + } }; } // namespace mtl