X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_fixed.h;h=7e8a59bf2166f8e7330a76ee7ee8e21fc5330e6f;hb=cee5940bae97612105db8b7e1ffcf513f9d9150c;hp=642e16409b068e389264623f3ea32f0468f1931a;hpb=dee84efa006428fdfbf0e84b66ee94eb23113ad9;p=synfig.git diff --git a/ETL/trunk/ETL/_fixed.h b/ETL/trunk/ETL/_fixed.h index 642e164..7e8a59b 100644 --- a/ETL/trunk/ETL/_fixed.h +++ b/ETL/trunk/ETL/_fixed.h @@ -74,7 +74,7 @@ template _ETL::fixed_base log template _ETL::fixed_base log10(const _ETL::fixed_base&); template _ETL::fixed_base pow(const _ETL::fixed_base&, int); template _ETL::fixed_base pow(const _ETL::fixed_base&, const T&); -template _ETL::fixed_base pow(const _ETL::fixed_base&, +template _ETL::fixed_base pow(const _ETL::fixed_base&, const _ETL::fixed_base&); template _ETL::fixed_base pow(const _ETL::fixed_base&, const _ETL::fixed_base&); template _ETL::fixed_base sin(const _ETL::fixed_base&); @@ -98,7 +98,7 @@ public: typedef T value_type; private: T _data; - + typedef fixed_base _fixed; typedef fixed_base self_type; @@ -119,7 +119,7 @@ public: 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; + T &data() ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; const T &data()const ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; const _fixed& operator+=(const _fixed &rhs) ETL_ATTRIB_INLINE; @@ -144,7 +144,7 @@ public: _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; @@ -158,7 +158,7 @@ public: _fixed floor()const; _fixed ceil()const; _fixed round()const; - + bool operator==(const _fixed &rhs)const { return data()==rhs.data(); } bool operator!=(const _fixed &rhs)const { return data()!=rhs.data(); } bool operator<(const _fixed &rhs)const { return data() fixed_base::fixed_base() -{} +{} template fixed_base::fixed_base(const _fixed &x):_data(x._data) @@ -197,55 +197,55 @@ fixed_base::fixed_base(value_type x,raw):_data(x) { } template fixed_base::fixed_base(const int &n,const int &d):_data((n< inline bool -fixed_base::_TYPE_SMALLER_THAN_INT() +fixed_base::_TYPE_SMALLER_THAN_INT() { return sizeof(T) inline bool -fixed_base::_USING_ALL_BITS() +fixed_base::_USING_ALL_BITS() { return sizeof(T)*8==FIXED_BITS; } template inline T -fixed_base::_ONE() +fixed_base::_ONE() { return static_cast((_USING_ALL_BITS()?~T(0):1< inline T -fixed_base::_F_MASK() +fixed_base::_F_MASK() { return static_cast(_USING_ALL_BITS()?~T(0):_ONE()-1); } template inline float -fixed_base::_EPSILON() +fixed_base::_EPSILON() { return 1.0f/((float)_ONE()*2); } template T & -fixed_base::data() +fixed_base::data() { return _data; } template const T & -fixed_base::data()const +fixed_base::data()const { return _data; } //! fixed+=fixed template const fixed_base & -fixed_base::operator+=(const fixed_base &rhs) +fixed_base::operator+=(const fixed_base &rhs) { _data+=rhs._data; return *this; @@ -253,7 +253,7 @@ fixed_base::operator+=(const fixed_base &rhs) //! fixed-=fixed template const fixed_base & -fixed_base::operator-=(const fixed_base &rhs) +fixed_base::operator-=(const fixed_base &rhs) { _data-=rhs._data; return *this; @@ -261,7 +261,7 @@ fixed_base::operator-=(const fixed_base &rhs) //! fixed*=fixed template const fixed_base & -fixed_base::operator*=(const fixed_base &rhs) +fixed_base::operator*=(const fixed_base &rhs) { if(_TYPE_SMALLER_THAN_INT()) _data=static_cast((int)_data*(int)rhs._data>>FIXED_BITS); @@ -270,13 +270,13 @@ fixed_base::operator*=(const fixed_base &rhs) _data*=rhs._data; _data>>=FIXED_BITS; } - + return *this; } //! fixed/=fixed template const fixed_base & -fixed_base::operator/=(const fixed_base &rhs) +fixed_base::operator/=(const fixed_base &rhs) { if(_TYPE_SMALLER_THAN_INT()) _data=static_cast((int)_data/(int)rhs._data<::operator/=(const fixed_base &rhs) } template template const fixed_base & -fixed_base::operator*=(const U &rhs) +fixed_base::operator*=(const U &rhs) { return operator*=(fixed_base(rhs)); } template template const fixed_base & -fixed_base::operator/=(const U &rhs) +fixed_base::operator/=(const U &rhs) { return operator/=(fixed_base(rhs)); } //! fixed*=int template const fixed_base & -fixed_base::operator*=(const int &rhs) +fixed_base::operator*=(const int &rhs) { _data*=rhs; return *this; } //! fixed/=int template const fixed_base & -fixed_base::operator/=(const int &rhs) +fixed_base::operator/=(const int &rhs) { _data/=rhs; return *this; } @@ -322,7 +322,7 @@ fixed_base::operator/=(const int &rhs) //! fixed + fixed template fixed_base -fixed_base::operator+(const fixed_base &rhs)const +fixed_base::operator+(const fixed_base &rhs)const { _fixed ret; ret._data=_data+rhs._data; @@ -331,7 +331,7 @@ fixed_base::operator+(const fixed_base &rhs)const //! fixed - fixed template fixed_base -fixed_base::operator-(const fixed_base &rhs)const +fixed_base::operator-(const fixed_base &rhs)const { _fixed ret; ret._data=_data-rhs._data; @@ -340,7 +340,7 @@ fixed_base::operator-(const fixed_base &rhs)const //! fixed * fixed template fixed_base -fixed_base::operator*(const fixed_base &rhs)const +fixed_base::operator*(const fixed_base &rhs)const { _fixed ret; ret._data=((_data*rhs._data)>>FIXED_BITS); @@ -350,7 +350,7 @@ fixed_base::operator*(const fixed_base &rhs)const //! fixed / fixed template fixed_base -fixed_base::operator/(const fixed_base &rhs)const +fixed_base::operator/(const fixed_base &rhs)const { _fixed ret; ret._data=((_data/rhs._data)<::operator/(const U &rhs) const //! fixed * int template fixed_base -fixed_base::operator*(const int &rhs)const +fixed_base::operator*(const int &rhs)const { _fixed ret; ret._data=_data*rhs; @@ -398,14 +398,14 @@ fixed_base::operator*(const int &rhs)const //! fixed * float template fixed_base -fixed_base::operator*(const float &rhs)const +fixed_base::operator*(const float &rhs)const { return (*this)*_fixed(rhs); } //! fixed * double template fixed_base -fixed_base::operator*(const double &rhs)const +fixed_base::operator*(const double &rhs)const { return (*this)*_fixed(rhs); } @@ -413,7 +413,7 @@ fixed_base::operator*(const double &rhs)const //! fixed / int template fixed_base -fixed_base::operator/(const int &rhs)const +fixed_base::operator/(const int &rhs)const { _fixed ret; ret._data=_data/rhs; @@ -423,14 +423,14 @@ fixed_base::operator/(const int &rhs)const //! float * fixed template fixed_base -operator*(const float& lhs, const fixed_base &rhs) +operator*(const float& lhs, const fixed_base &rhs) { return rhs*lhs; } //! double * fixed template fixed_base -operator*(const double& lhs, const fixed_base &rhs) +operator*(const double& lhs, const fixed_base &rhs) { return rhs*lhs; } @@ -442,38 +442,38 @@ operator*(const double& lhs, const fixed_base &rhs) // Negation Operator template fixed_base -fixed_base::operator-()const +fixed_base::operator-()const { _fixed ret; ret._data=-_data; return ret; } // Casting Operators template -fixed_base::operator float()const +fixed_base::operator float()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator double()const +fixed_base::operator double()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator long double()const +fixed_base::operator long double()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator int()const +fixed_base::operator int()const { return static_cast(_data>>FIXED_BITS); } template -fixed_base::operator bool()const +fixed_base::operator bool()const { return static_cast(_data); }