65 operator float()
const
84 unsigned int float_value = ((hf & 0x8000) << 16) | (((hf & 0x7c00) + 0x1C000) << 13) | ((hf & 0x03FF) << 13);
85 void *ptr =
static_cast<void*
>(&float_value);
86 return *
static_cast<float*
>(ptr);
92 void *ptr =
static_cast<void*
>(&float_value);
93 unsigned int f = *
static_cast<unsigned int*
>(ptr);
94 return ((
f >> 16) & 0x8000) | ((((
f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | ((
f >> 13) & 0x03ff);
99 unsigned int float_value = mantissa_table[offset_table[hf >> 10] + (hf & 0x3ff)] + exponent_table[hf >> 10];
100 void *ptr =
static_cast<void*
>(&float_value);
101 return *
static_cast<float*
>(ptr);
106 void *ptr =
static_cast<void*
>(&float_value);
107 unsigned int f = *
static_cast<unsigned int*
>(ptr);
108 return base_table[(
f >> 23) & 0x1ff] + ((
f & 0x007fffff) >> shift_table[(
f >> 23) & 0x1ff]);
112 unsigned short value;
114 static unsigned int mantissa_table[2048];
115 static unsigned int exponent_table[64];
116 static unsigned short offset_table[64];
118 static unsigned short base_table[512];
119 static unsigned char shift_table[512];
static float half_to_float(unsigned short hf)
Definition: half_float.h:97
float to_float() const
Definition: half_float.h:70
static unsigned short float_to_half_simple(float float_value)
Only works for 'normal' half-float values.
Definition: half_float.h:90
Definition: half_float.h:40
HalfFloat(float v)
Definition: half_float.h:50
HalfFloat(const HalfFloat &other)
Definition: half_float.h:46
HalfFloat & from_float(float v)
Definition: half_float.h:75
HalfFloat()
Definition: half_float.h:42
static unsigned short float_to_half(float float_value)
Definition: half_float.h:104
static float half_to_float_simple(unsigned short hf)
Only works for 'normal' half-float values.
Definition: half_float.h:82
HalfFloat & operator=(const HalfFloat &other)
Definition: half_float.h:54