I have class for floating point format where the size of the mantissa and the exponent can be specified as a template parameter:
template <int _m_size, int _exp_size>
class fpxx {
public:
const int exp_size = _exp_size;
const int m_size = _m_size;
bool sign;
unsigned exp;
unsigned m;
...
}
I also have a friend operator+ to add 2 such numbers:
friend fpxx<_m_size, _exp_size> operator+(const fpxx<_m_size, _exp_size> left, const fpxx<_m_size, _exp_size> right)
{
...
}
This works fine.
It allows me to do things like this:
fpxx<18,5> a, b, r;
r = a + b;
However, I would also be able create an operator+ friend that makes it possible to add numbers with different mantissa and exponent sizes. Like this:
fpxx<10,4> a;
fpxx<12,4> a;
fpxx<18,5> r;
r = a + b;
But I have no idea how to do declare the function for that.
Is this possible?
Thanks! Tom