X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_fixed.h;h=642e16409b068e389264623f3ea32f0468f1931a;hb=0ff680f220a26f171851ab3bf04df1a154cc95f9;hp=cf69fc12f0327a40fc5414d47ee0fc6468581a32;hpb=b3016b249333ac0ab0008d8c6c4d9029b2ff30c9;p=synfig.git diff --git a/ETL/trunk/ETL/_fixed.h b/ETL/trunk/ETL/_fixed.h index cf69fc1..642e164 100644 --- a/ETL/trunk/ETL/_fixed.h +++ b/ETL/trunk/ETL/_fixed.h @@ -111,12 +111,12 @@ private: class raw { }; public: fixed_base()ETL_ATTRIB_INLINE; - fixed_base(const _fixed &x)ETL_ATTRIB_INLINE; fixed_base(const float &f)ETL_ATTRIB_INLINE; fixed_base(const double &f)ETL_ATTRIB_INLINE; fixed_base(const long double &f)ETL_ATTRIB_INLINE; fixed_base(const int &i)ETL_ATTRIB_INLINE; fixed_base(const int &n,const int &d)ETL_ATTRIB_INLINE; //!< Fraction constructor + fixed_base(const _fixed &x)ETL_ATTRIB_INLINE; fixed_base(value_type x,raw)ETL_ATTRIB_INLINE; T &data() ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; @@ -142,6 +142,8 @@ public: _fixed operator/(const _fixed &rhs)const ETL_ATTRIB_INLINE; _fixed operator*(const int &rhs)const ETL_ATTRIB_INLINE; _fixed operator/(const int &rhs)const ETL_ATTRIB_INLINE; + _fixed operator*(const float &rhs)const ETL_ATTRIB_INLINE; + _fixed operator*(const double &rhs)const ETL_ATTRIB_INLINE; // Negation Operator _fixed operator-()const ETL_ATTRIB_INLINE; @@ -175,15 +177,15 @@ fixed_base::fixed_base(const _fixed &x):_data(x._data) {} template -fixed_base::fixed_base(const float &f):_data(static_cast(f*_ONE()+0.5f)) +fixed_base::fixed_base(const float &f):_data(static_cast(f*_ONE()/*+0.5f*/)) {} template -fixed_base::fixed_base(const double &f):_data(static_cast(f*_ONE()+0.5)) +fixed_base::fixed_base(const double &f):_data(static_cast(f*_ONE()/*+0.5*/)) {} template -fixed_base::fixed_base(const long double &f):_data(static_cast(f*_ONE()+0.5)) +fixed_base::fixed_base(const long double &f):_data(static_cast(f*_ONE()/*+0.5*/)) {} template @@ -394,6 +396,21 @@ fixed_base::operator*(const int &rhs)const //return reinterpret_cast<_fixed>(_data*rhs); } +//! fixed * float +template fixed_base +fixed_base::operator*(const float &rhs)const +{ + return (*this)*_fixed(rhs); +} + +//! fixed * double +template fixed_base +fixed_base::operator*(const double &rhs)const +{ + return (*this)*_fixed(rhs); +} + + //! fixed / int template fixed_base fixed_base::operator/(const int &rhs)const @@ -404,7 +421,19 @@ fixed_base::operator/(const int &rhs)const //return reinterpret_cast<_fixed>(_data/rhs); } +//! float * fixed +template fixed_base +operator*(const float& lhs, const fixed_base &rhs) +{ + return rhs*lhs; +} +//! double * fixed +template fixed_base +operator*(const double& lhs, const fixed_base &rhs) +{ + return rhs*lhs; +}