diff --git a/fixed.cpp b/fixed.cpp index 6f4d0fb3..055d47be 100644 --- a/fixed.cpp +++ b/fixed.cpp @@ -96,6 +96,33 @@ fixed::to_integer (uint_t n) } +/////////////////////////////////////////////////////////////////////////////// +// Fixed operators +#define SIMPLE_FIXED_REF(OP) \ +template \ +util::fixed& \ +util::fixed::operator OP (const fixed rhs) \ +{ \ + m_value OP rhs.m_value; \ + return *this; \ +} + +SIMPLE_FIXED_REF(-=) +SIMPLE_FIXED_REF(+=) + + +#define SIMPLE_FIXED_LIT(OP) \ +template \ +util::fixed \ +util::fixed::operator OP (const fixed rhs) const \ +{ \ + return fixed {m_value OP rhs.m_value}; \ +} + +SIMPLE_FIXED_LIT(-) +SIMPLE_FIXED_LIT(+) + + /////////////////////////////////////////////////////////////////////////////// // Integer operators