fixed: implement addition/subtraction

This commit is contained in:
Danny Robson 2015-02-06 19:01:38 +11:00
parent 1d2d32e016
commit a218774bc0

View File

@ -96,6 +96,33 @@ fixed<I,E>::to_integer (uint_t n)
}
///////////////////////////////////////////////////////////////////////////////
// Fixed operators
#define SIMPLE_FIXED_REF(OP) \
template <unsigned I, unsigned E> \
util::fixed<I,E>& \
util::fixed<I,E>::operator OP (const fixed<I,E> rhs) \
{ \
m_value OP rhs.m_value; \
return *this; \
}
SIMPLE_FIXED_REF(-=)
SIMPLE_FIXED_REF(+=)
#define SIMPLE_FIXED_LIT(OP) \
template <unsigned I, unsigned E> \
util::fixed<I,E> \
util::fixed<I,E>::operator OP (const fixed<I,E> rhs) const \
{ \
return fixed<I,E> {m_value OP rhs.m_value}; \
}
SIMPLE_FIXED_LIT(-)
SIMPLE_FIXED_LIT(+)
///////////////////////////////////////////////////////////////////////////////
// Integer operators