108 constexpr
half (
const half&
h) =
default;
115 operator float ()
const;
222 GF_API static short convert (
int i);
223 GF_API static float overflow ();
227 GF_API static const uif _toFloat[1 << 16];
228 GF_API static const unsigned short _eLut[1 << 9];
259 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
261 #define HALF_MIN 5.96046448e-08f // Smallest positive half
263 #define HALF_NRM_MIN 6.10351562e-05f // Smallest positive normalized half
265 #define HALF_MAX 65504.0f // Largest positive half
267 #define HALF_EPSILON 0.00097656f // Smallest positive e for which
271 #define HALF_MIN 5.96046448e-08 // Smallest positive half
273 #define HALF_NRM_MIN 6.10351562e-05 // Smallest positive normalized half
275 #define HALF_MAX 65504.0 // Largest positive half
277 #define HALF_EPSILON 0.00097656 // Smallest positive e for which
282 #define HALF_MANT_DIG 11 // Number of digits in mantissa
287 #define HALF_DIG 3 // Number of base 10 digits that
291 #define HALF_DECIMAL_DIG 5 // Number of base-10 digits that are
295 #define HALF_RADIX 2 // Base of the exponent
297 #define HALF_MIN_EXP -13 // Minimum negative integer such that
302 #define HALF_MAX_EXP 16 // Maximum positive integer such that
307 #define HALF_MIN_10_EXP -4 // Minimum positive integer such
311 #define HALF_MAX_10_EXP 4 // Maximum positive integer such
466 int e = (x.
i >> 23) & 0x000001ff;
477 int m = x.
i & 0x007fffff;
478 _h = e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13);
497 half::operator float ()
const
499 return _toFloat[_h].f;
522 unsigned short s = _h & 0x8000;
523 unsigned short e = _h & 0x7fff;
586 *
this =
half (
float (*
this) +
float (h));
594 *
this =
half (
float (*
this) + f);
602 *
this =
half (
float (*
this) -
float (h));
610 *
this =
half (
float (*
this) - f);
618 *
this =
half (
float (*
this) *
float (h));
626 *
this =
half (
float (*
this) * f);
634 *
this =
half (
float (*
this) /
float (h));
642 *
this =
half (
float (*
this) / f);
650 unsigned short e = (_h >> 10) & 0x001f;
658 unsigned short e = (_h >> 10) & 0x001f;
659 return e > 0 && e < 31;
666 unsigned short e = (_h >> 10) & 0x001f;
667 unsigned short m = _h & 0x3ff;
668 return e == 0 && m != 0;
675 return (_h & 0x7fff) == 0;
682 unsigned short e = (_h >> 10) & 0x001f;
683 unsigned short m = _h & 0x3ff;
684 return e == 31 && m != 0;
691 unsigned short e = (_h >> 10) & 0x001f;
692 unsigned short m = _h & 0x3ff;
693 return e == 31 && m == 0;
700 return (_h & 0x8000) != 0;
740 inline unsigned short
GF_API std::istream & operator>>(std::istream &is, half &h)
half & operator/=(half h)
bool isDenormalized() const
GF_API std::ostream & operator<<(std::ostream &os, half h)
GF_API void printBits(std::ostream &os, half h)
bool isNormalized() const
GLint GLint GLint GLint GLint x
GF_API unsigned short bits() const
GLfloat GLfloat GLfloat GLfloat h
half round(unsigned int n) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
half & operator*=(half h)
half & operator-=(half h)
#define PXR_NAMESPACE_CLOSE_SCOPE
half & operator+=(half h)
half & operator=(const half &)=default
GF_API void setBits(unsigned short bits)