62 operator float()
const
81 unsigned int float_value = ((hf & 0x8000) << 16) | (((hf & 0x7c00) + 0x1C000) << 13) | ((hf & 0x03FF) << 13);
82 void *ptr =
static_cast<void*
>(&float_value);
83 return *
static_cast<float*
>(ptr);
89 void *ptr =
static_cast<void*
>(&float_value);
90 unsigned int f = *
static_cast<unsigned int*
>(ptr);
91 return ((
f >> 16) & 0x8000) | ((((
f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | ((
f >> 13) & 0x03ff);
96 unsigned int float_value = mantissa_table[offset_table[hf >> 10] + (hf & 0x3ff)] + exponent_table[hf >> 10];
97 void *ptr =
static_cast<void*
>(&float_value);
98 return *
static_cast<float*
>(ptr);
103 void *ptr =
static_cast<void*
>(&float_value);
104 unsigned int f = *
static_cast<unsigned int*
>(ptr);
105 return base_table[(
f >> 23) & 0x1ff] + ((
f & 0x007fffff) >> shift_table[(
f >> 23) & 0x1ff]);
109 unsigned short value;
111 static unsigned int mantissa_table[2048];
112 static unsigned int exponent_table[64];
113 static unsigned short offset_table[64];
115 static unsigned short base_table[512];
116 static unsigned char shift_table[512];
Definition: half_float.h:37
static float half_to_float(unsigned short hf)
Definition: half_float.h:94
static unsigned short float_to_half_simple(float float_value)
Only works for 'normal' half-float values.
Definition: half_float.h:87
HalfFloat()
Definition: half_float.h:39
float to_float() const
Definition: half_float.h:67
HalfFloat & operator=(const HalfFloat &other)
Definition: half_float.h:51
static unsigned short float_to_half(float float_value)
Definition: half_float.h:101
HalfFloat(const HalfFloat &other)
Definition: half_float.h:43
static float half_to_float_simple(unsigned short hf)
Only works for 'normal' half-float values.
Definition: half_float.h:79
HalfFloat & from_float(float v)
Definition: half_float.h:72
HalfFloat(float v)
Definition: half_float.h:47