85#ifndef OPENVDB_MATH_HALF_HAS_BEEN_INCLUDED
86#define OPENVDB_MATH_HALF_HAS_BEEN_INCLUDED
89#include <openvdb/version.h>
117 operator
float () const;
124 half operator - () const;
133 half & operator = (
float f);
136 half & operator += (
float f);
139 half & operator -= (
float f);
142 half & operator *= (
float f);
145 half & operator /= (
float f);
154 half round (
unsigned int n) const;
178 bool isFinite () const;
179 bool isNormalized () const;
180 bool isDenormalized () const;
181 bool isZero () const;
183 bool isInfinity () const;
184 bool isNegative () const;
201 static
half posInf ();
202 static
half negInf ();
211 unsigned short bits () const;
212 void setBits (
unsigned short bits);
225 static short convert (
int i);
226 static float overflow ();
230 static const uif _toFloat[1 << 16];
231 static const unsigned short _eLut[1 << 9];
262#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
264 #define VDB_HALF_MIN 5.96046448e-08f
266 #define VDB_HALF_NRM_MIN 6.10351562e-05f
268 #define VDB_HALF_MAX 65504.0f
270 #define VDB_HALF_EPSILON 0.00097656f
274 #define VDB_HALF_MIN 5.96046448e-08
276 #define VDB_HALF_NRM_MIN 6.10351562e-05
278 #define VDB_HALF_MAX 65504.0
280 #define VDB_HALF_EPSILON 0.00097656
285#define VDB_HALF_MANT_DIG 11
290#define VDB_HALF_DIG 3
294#define VDB_HALF_DECIMAL_DIG 5
298#define VDB_HALF_RADIX 2
300#define VDB_HALF_MIN_EXP -13
305#define VDB_HALF_MAX_EXP 16
310#define VDB_HALF_MIN_10_EXP -4
314#define VDB_HALF_MAX_10_EXP 4
449 _h = (
unsigned short)(x.
i >> 16);
469 int e = (x.
i >> 23) & 0x000001ff;
480 int m = x.
i & 0x007fffff;
481 _h = (
unsigned short)(e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13));
500half::operator float ()
const
502 return _toFloat[_h].f;
511half::round (
unsigned int n)
const
525 unsigned short s = _h & 0x8000;
526 unsigned short e = _h & 0x7fff;
535 e = (
unsigned short)(e >> (9 - n));
536 e = (
unsigned short)(e + (e & 1));
537 e = (
unsigned short)(e << (9 - n));
550 e = (
unsigned short)(e >> (10 - n));
551 e = (
unsigned short)(e << (10 - n));
559 h._h = (
unsigned short)(s | e);
570half::operator - ()
const
579half::operator = (
float f)
589 *
this =
half (
float (*
this) +
float (h));
595half::operator += (
float f)
597 *
this =
half (
float (*
this) + f);
605 *
this =
half (
float (*
this) -
float (h));
611half::operator -= (
float f)
613 *
this =
half (
float (*
this) - f);
621 *
this =
half (
float (*
this) *
float (h));
627half::operator *= (
float f)
629 *
this =
half (
float (*
this) * f);
637 *
this =
half (
float (*
this) /
float (h));
643half::operator /= (
float f)
645 *
this =
half (
float (*
this) / f);
651half::isFinite ()
const
653 unsigned short e = (_h >> 10) & 0x001f;
659half::isNormalized ()
const
661 unsigned short e = (_h >> 10) & 0x001f;
662 return e > 0 && e < 31;
667half::isDenormalized ()
const
669 unsigned short e = (_h >> 10) & 0x001f;
670 unsigned short m = _h & 0x3ff;
671 return e == 0 && m != 0;
678 return (_h & 0x7fff) == 0;
685 unsigned short e = (_h >> 10) & 0x001f;
686 unsigned short m = _h & 0x3ff;
687 return e == 31 && m != 0;
692half::isInfinity ()
const
694 unsigned short e = (_h >> 10) & 0x001f;
695 unsigned short m = _h & 0x3ff;
696 return e == 31 && m == 0;
701half::isNegative ()
const
703 return (_h & 0x8000) != 0;
751half::setBits (
unsigned short bits)
half(half &&) noexcept=default
half(const half &)=default
OPENVDB_API void printBits(std::ostream &os, half h)
Definition: Exceptions.h:13
unsigned int i
Definition: Half.h:219
float f
Definition: Half.h:220
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212