Add fixed point comparison operators

This commit is contained in:
Madeline Busig 2024-08-18 14:10:44 -07:00
parent 0711ec1fc1
commit 543218e489

View File

@ -167,6 +167,28 @@ public:
*this = *this / rhs; *this = *this / rhs;
return *this; 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 } // namespace mtl