1 #ifndef _REAL_FAST2SUM_H
2 #define _REAL_FAST2SUM_H
5 // otherwise the abs() function won't work
10 template <class T = float>
13 RealF2S(const T & value = 0.0L) : m_value(value) {} //{Debug("Construct from value %f", m_value);}
14 RealF2S(const RealF2S & cpy) : m_value(cpy.m_value) {} //{Debug("Copy construct from value %f", m_value);}
16 RealF2S & operator+=(const RealF2S & a) {this->operator=(RealF2S(*this) + a); return *this;}
17 RealF2S & operator-=(const RealF2S & a) {this->operator=(RealF2S(*this) - a); return *this;}
18 RealF2S & operator*=(const RealF2S & a) {this->operator=(RealF2S(*this) * a); return *this;}
19 RealF2S & operator/=(const RealF2S & a) {this->operator=(RealF2S(*this) / a); return *this;}
21 RealF2S & operator=(const RealF2S & equ) {this->m_value = equ.m_value; return *this;}
22 RealF2S & operator=(const T & equ) {this->m_value = equ.m_value; return *this;}
29 template <class T> RealF2S<T> operator+(const RealF2S<T> & a, const RealF2S<T> & b)
32 if (abs(T(a.m_value)) < abs(T(b.m_value)))
34 T z = a.m_value + b.m_value;
37 return RealF2S<T>(z + zz);
39 template <class T> RealF2S<T> operator-(const RealF2S<T> & a, const RealF2S<T> & b)
42 return a + RealF2S<T>(-b.m_value);
45 template <class T> RealF2S<T> operator*(const RealF2S<T> & a, const RealF2S<T> & b)
47 return RealF2S<T>(a.m_value * b.m_value);
49 template <class T> RealF2S<T> operator/(const RealF2S<T> & a, const RealF2S<T> & b)
51 return RealF2S<T>(a.m_value / b.m_value);
57 #endif //_REAL_FAST2SUM_H