Add fixed point assignment operators

This commit is contained in:
Myles Busig 2024-08-02 23:27:13 -06:00
parent d681363a7b
commit 55edb9f634

View File

@ -105,12 +105,20 @@ public:
constexpr fixed operator+(fixed rhs) const {
return from_raw(x + rhs.x);
}
constexpr fixed& operator+=(fixed rhs) {
x += rhs.x;
return *this;
}
/**
* \brief Fixed point subtraction
*/
constexpr fixed operator-(fixed rhs) const {
return from_raw(x - rhs.x);
}
constexpr fixed& operator-=(fixed rhs) {
x -= rhs.x;
return *this;
}
constexpr fixed operator-() const {
return from_raw(-x);
}
@ -135,6 +143,10 @@ public:
return from_raw(raw_result);
}
fixed& operator*=(fixed rhs) {
*this = *this * rhs;
return *this;
}
/**
* \brief Fixed point division
@ -152,6 +164,10 @@ public:
* Placed in IWRAM
*/
fixed operator/(fixed rhs) const;
fixed& operator/=(fixed rhs) {
*this = *this / rhs;
return *this;
}
};
} // namespace mtl