4 #if defined(MTS_HAS_OPENEXR)
94 #include <mitsuba/mitsuba.h>
112 operator float ()
const;
119 half operator - ()
const;
127 half & operator = (
float f);
130 half & operator += (
float f);
133 half & operator -= (
float f);
136 half & operator *= (
float f);
139 half & operator /= (
float f);
148 half round (
unsigned int n)
const;
172 bool isFinite ()
const;
173 bool isNormalized ()
const;
174 bool isDenormalized ()
const;
175 bool isZero ()
const;
177 bool isInfinity ()
const;
178 bool isNegative ()
const;
195 static half posInf ();
196 static half negInf ();
205 unsigned short bits ()
const;
206 void setBits (
unsigned short bits);
219 static short convert (
int i);
220 static float overflow ();
224 static uif _toFloat[1 << 16];
225 static unsigned short _eLut[1 << 9];
254 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
256 #define HALF_MIN 5.96046448e-08f // Smallest positive half
258 #define HALF_NRM_MIN 6.10351562e-05f // Smallest positive normalized half
260 #define HALF_MAX 65504.0f // Largest positive half
262 #define HALF_EPSILON 0.00097656f // Smallest positive e for which
266 #define HALF_MIN 5.96046448e-08 // Smallest positive half
268 #define HALF_NRM_MIN 6.10351562e-05 // Smallest positive normalized half
270 #define HALF_MAX 65504.0 // Largest positive half
272 #define HALF_EPSILON 0.00097656 // Smallest positive e for which
277 #define HALF_MANT_DIG 11 // Number of digits in mantissa
280 #define HALF_DIG 2 // Number of base 10 digits that
283 #define HALF_RADIX 2 // Base of the exponent
285 #define HALF_MIN_EXP -13 // Minimum negative integer such that
290 #define HALF_MAX_EXP 16 // Maximum positive integer such that
295 #define HALF_MIN_10_EXP -4 // Minimum positive integer such
299 #define HALF_MAX_10_EXP 4 // Maximum positive integer such
465 register int e = (x.
i >> 23) & 0x000001ff;
476 register int m = x.
i & 0x007fffff;
477 _h = e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13);
496 half::operator float ()
const
498 return _toFloat[_h].f;
521 unsigned short s = _h & 0x8000;
522 unsigned short e = _h & 0x7fff;
593 *
this =
half (
float (*
this) +
float (h));
601 *
this =
half (
float (*
this) + f);
609 *
this =
half (
float (*
this) -
float (h));
617 *
this =
half (
float (*
this) - f);
625 *
this =
half (
float (*
this) *
float (h));
633 *
this =
half (
float (*
this) * f);
641 *
this =
half (
float (*
this) /
float (h));
649 *
this =
half (
float (*
this) / f);
657 unsigned short e = (_h >> 10) & 0x001f;
665 unsigned short e = (_h >> 10) & 0x001f;
666 return e > 0 && e < 31;
673 unsigned short e = (_h >> 10) & 0x001f;
674 unsigned short m = _h & 0x3ff;
675 return e == 0 && m != 0;
682 return (_h & 0x7fff) == 0;
689 unsigned short e = (_h >> 10) & 0x001f;
690 unsigned short m = _h & 0x3ff;
691 return e == 31 && m != 0;
698 unsigned short e = (_h >> 10) & 0x001f;
699 unsigned short m = _h & 0x3ff;
700 return e == 31 && m == 0;
707 return (_h & 0x8000) != 0;
747 inline unsigned short
767 static const bool is_specialized =
true;
774 static const bool is_signed =
true;
775 static const bool is_integer =
false;
776 static const bool is_exact =
false;
786 static const bool has_infinity =
true;
787 static const bool has_quiet_NaN =
true;
788 static const bool has_signaling_NaN =
true;
789 static const float_denorm_style has_denorm = denorm_present;
790 static const bool has_denorm_loss =
false;
796 static const bool is_iec559 =
false;
797 static const bool is_bounded =
false;
798 static const bool is_modulo =
false;
800 static const bool traps =
true;
801 static const bool tinyness_before =
false;
802 static const float_round_style round_style = round_to_nearest;
half & operator*=(half h)
Definition: half.h:623
bool isDenormalized() const
Definition: half.h:671
static half min()
Definition: half.h:769
bool isFinite() const
Definition: half.h:655
bool isNormalized() const
Definition: half.h:663
unsigned int i
Definition: half.h:213
half & operator/=(half h)
Definition: half.h:639
static half posInf()
Definition: half.h:712
bool isNegative() const
Definition: half.h:705
#define HALF_MIN_EXP
Definition: half.h:285
void printBits(std::ostream &os, half h)
#define HALF_NRM_MIN
Definition: half.h:268
static half infinity()
Definition: half.h:791
static half sNan()
Definition: half.h:739
float f
Definition: half.h:214
half round(unsigned int n) const
Definition: half.h:507
#define MTS_EXPORT_CORE
Definition: getopt.h:29
static half negInf()
Definition: half.h:721
bool isZero() const
Definition: half.h:680
#define HALF_MANT_DIG
Definition: half.h:277
bool isInfinity() const
Definition: half.h:696
#define HALF_MAX_10_EXP
Definition: half.h:299
bool isNan() const
Definition: half.h:687
half()
Definition: half.h:421
half & operator+=(half h)
Definition: half.h:591
static half max()
Definition: half.h:770
#define HALF_RADIX
Definition: half.h:283
static half denorm_min()
Definition: half.h:794
#define HALF_MIN_10_EXP
Definition: half.h:295
std::istream & operator>>(std::istream &is, half &h)
static half epsilon()
Definition: half.h:778
#define HALF_DIG
Definition: half.h:280
#define HALF_EPSILON
Definition: half.h:272
void setBits(unsigned short bits)
Definition: half.h:755
#define HALF_MAX
Definition: half.h:270
#define HALF_MIN
Definition: half.h:266
std::ostream & operator<<(std::ostream &os, half h)
half operator-() const
Definition: half.h:566
static half round_error()
Definition: half.h:779
static half quiet_NaN()
Definition: half.h:792
unsigned short bits() const
Definition: half.h:748
#define HALF_MAX_EXP
Definition: half.h:290
static half signaling_NaN()
Definition: half.h:793
static half qNan()
Definition: half.h:730
half & operator-=(half h)
Definition: half.h:607
half & operator=(half h)
Definition: half.h:575