Changeset 869 for trunk/src/half.h
 Timestamp:
 Aug 28, 2011, 11:07:06 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/half.h
r867 r869 35 35 } 36 36 37 inline int isnan() const 38 { 39 return ((m_bits & 0x7c00u) == 0x7c00u) && (m_bits & 0x03ffu); 40 } 41 42 inline int isfinite() const 43 { 44 return (m_bits & 0x7c00u) != 0x7c00u; 45 } 46 47 inline int isinf() const 48 { 49 return (uint16_t)(m_bits << 1) == (0x7c00u << 1); 50 } 51 52 inline int isnormal() const 53 { 54 return (isfinite() && (m_bits & 0x7c00u))  ((m_bits & 0x7fffu) == 0); 55 } 56 57 inline uint16_t bits() 58 { 59 return m_bits; 60 } 61 62 /* Cast to other types */ 63 operator float() const; 64 inline operator int() const { return (int)(float)*this; } 65 66 /* Factories */ 37 67 static half makeslow(float f); 38 68 static half makefast(float f); 39 40 69 static inline half makebits(uint16_t x) 41 70 { … … 43 72 ret.m_bits = x; 44 73 return ret; 45 }46 47 inline operator float() const48 {49 int s = m_bits & 0x8000u;50 int e = m_bits & 0x7c00u;51 int m = m_bits & 0x03ffu;52 53 union { float f; uint32_t x; } u;54 u.x = 0;55 u.x = s << 16;56 u.x = (15 + (e >> 10) + 127) << 23;57 u.x = m << 13;58 59 return u.f;60 }61 62 inline uint16_t bits()63 {64 return m_bits;65 74 } 66 75 };
Note: See TracChangeset
for help on using the changeset viewer.