Changeset 871 for trunk/src/half.h


Ignore:
Timestamp:
Aug 28, 2011, 11:07:12 PM (8 years ago)
Author:
sam
Message:

core: implement new half / float operations and the associated tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/half.h

    r869 r871  
    6464    inline operator int() const { return (int)(float)*this; }
    6565
     66    /* Operations */
     67    inline half operator -() { return makebits(m_bits ^ 0x8000u); }
     68    inline half &operator +=(float f) { return (*this = (half)(*this + f)); }
     69    inline half &operator -=(float f) { return (*this = (half)(*this - f)); }
     70    inline half &operator *=(float f) { return (*this = (half)(*this * f)); }
     71    inline half &operator /=(float f) { return (*this = (half)(*this / f)); }
     72    inline half &operator +=(half h) { return (*this = (half)(*this + h)); }
     73    inline half &operator -=(half h) { return (*this = (half)(*this - h)); }
     74    inline half &operator *=(half h) { return (*this = (half)(*this * h)); }
     75    inline half &operator /=(half h) { return (*this = (half)(*this / h)); }
     76
     77    inline float operator +(float f) const { return (float)*this + f; }
     78    inline float operator -(float f) const { return (float)*this - f; }
     79    inline float operator *(float f) const { return (float)*this * f; }
     80    inline float operator /(float f) const { return (float)*this / f; }
     81    inline float operator +(half h) const { return (float)*this + (float)h; }
     82    inline float operator -(half h) const { return (float)*this - (float)h; }
     83    inline float operator *(half h) const { return (float)*this * (float)h; }
     84    inline float operator /(half h) const { return (float)*this / (float)h; }
     85
    6686    /* Factories */
    6787    static half makeslow(float f);
     
    7595};
    7696
     97inline float &operator +=(float &f, half h) { return f += (float)h; }
     98inline float &operator -=(float &f, half h) { return f -= (float)h; }
     99inline float &operator *=(float &f, half h) { return f *= (float)h; }
     100inline float &operator /=(float &f, half h) { return f /= (float)h; }
     101
     102inline float operator +(float f, half h) { return f + (float)h; }
     103inline float operator -(float f, half h) { return f - (float)h; }
     104inline float operator *(float f, half h) { return f * (float)h; }
     105inline float operator /(float f, half h) { return f / (float)h; }
     106
    77107} /* namespace lol */
    78108
Note: See TracChangeset for help on using the changeset viewer.